-
-
Notifications
You must be signed in to change notification settings - Fork 23.5k
Address remaining feedback on Android background transparency #107473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address remaining feedback on Android background transparency #107473
Conversation
55c8fbe to
7785a65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m4gr3d This looks really good now. But I'm still having one issue, the surface doesn't seems to be updated/refreshed properly.
| default void setPixelFormat(int format) { | ||
| SurfaceView surfaceView = getView(); | ||
| if (surfaceView != null && surfaceView.getHolder() != null) { | ||
| surfaceView.getHolder().setFormat(format); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just setting the format doesn't seems to be enough. The surface needs to be updated/refreshed.
I tried refreshing it with an hack and it seems to work for vulkan but opengl is still buggy.
Before my hack (This PR):
Opengl
Screenrecorder-2025-06-13-17-16-09-513.mp4
Vulkan
Screenrecorder-2025-06-13-17-14-53-256.mp4
After my hack
Opengl
Screenrecorder-2025-06-13-19-28-17-173.mp4
Vulkan
Screenrecorder-2025-06-13-19-29-20-652.mp4
| default void setPixelFormat(int format) { | ||
| SurfaceView surfaceView = getView(); | ||
| if (surfaceView != null && surfaceView.getHolder() != null) { | ||
| surfaceView.getHolder().setFormat(format); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My hack is simply hiding and then showing the view. But I believe you can come up with a better solution :)
surfaceView.getHolder().setFormat(format);
surfaceView.setVisibility(View.GONE);
surfaceView.setVisibility(View.VISIBLE);
c7c426b to
4ca7722
Compare
|
OK on Samsung Tab S7 with Mobile Renderer. (Android 13) Not on Pixel 8a, Mali GPU. (Android 16) OpenGLES/Compatibility is faulty on both devices, making it seem as if the app is frozen. Changing |
|
Note: In the demo, |
3f5d56d to
5296b54
Compare
5296b54 to
3ade4b4
Compare
|
@syntaxerror247 @Alex2782 After some explorations, it doesn't look like we can (yet) support switching transparency at runtime. The update to the pixel format causes the surface to be destroyed and recreated. On opengl on Android, we don't support that at all, and typically restart the app when such event occurs (see godot/platform/android/java_godot_lib_jni.cpp Line 239 in 4d1f26e
With vulkan, things are a bit better and we can continue without having to restart the app, but doing so still seems to create some issues as a bunch of warnings appear in the logs following the surface recreation. TLDR; handling surface recreation is an area we'll need to improve on before we're able to enable switching transparency on/off at runtime. cc @clayjohn If Edit: I've created #108386 to track the described issue with the vulkan renderer. |
See also godotengine/godot-proposals#6423. |
|
@syntaxerror247 @Alex2782 Ping on this PR. Note that I think I may have an approach to enable switching the transparency at runtime, but this builds on top of an upcoming large set of changes, so that capability would be 4.6 at the earliest. In the meantime, we should move ahead with the current capability and limitations for 4.5. |
|
Thanks! |
Follow up to #106709 to address #106709 (comment)