Fix transparency background issue on Android#106709
Conversation
|
Switching to draft until #106724 is merged. |
335cc7e to
7a15ea7
Compare
There was a problem hiding this comment.
Test project: godot-demo-projects/.../window_management
DisplayServer.has_feature(DisplayServer.FEATURE_WINDOW_TRANSPARENCY)
Can we activate that now too? Or evaluate android:windowIsTranslucent there?
There was a problem hiding this comment.
Test project: godot-demo-projects/.../window_management
display/window/size/transparent = true and disabled DisplayServer.has_feature check:
func _on_transparent_check_button_toggled(button_pressed: bool) -> void:
#if not DisplayServer.has_feature(DisplayServer.FEATURE_WINDOW_TRANSPARENCY):
# OS.alert("Window transparency is not supported by the current display server (%s)." % DisplayServer.get_name())
# return
get_viewport().transparent_bg = button_pressed
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_TRANSPARENT, button_pressed)
On Android 13, Samsung Tab S7 (Adreno 650).
OpenGL
glsl_Screen_recording_20250529_015017.mp4
Vulkan (Mobile)
mobile_Screen_recording_20250529_015358.mp4
on MacOS, Metal (Mobile) for comparison
Screen-2025-05-29-020905.mp4
At first glance OpenGL Renderer works correctly / as it should.
But after switching back and forth for the second time, the 3D scene is no longer rendered.
But these are other issues that have nothing to do with this PR. (i think)

There was a problem hiding this comment.
Test project: godot-demo-projects/.../window_management
In the test project, display/window/size/transparent isn't enabled, so I tried without it and didn't encounter any problems. Or is there anything wrong with that?
removed size/transparent from export_plugin.cpp
bool EditorExportPlatformAndroid::_should_be_transparent(const Ref<EditorExportPreset> &p_preset) const {
return (bool)get_project_setting(p_preset, "display/window/per_pixel_transparency/allowed");
}and Godot.kt
// Check whether the render view should be made transparent
val shouldBeTransparent = java.lang.Boolean.parseBoolean(GodotLib.getGlobal("display/window/per_pixel_transparency/allowed"))
@Alex2782 That's because |
7a15ea7 to
bdd0946
Compare
I've updated the logic to only check |
bdd0946 to
a72586f
Compare
There was a problem hiding this comment.
Test project: godot-demo-projects/.../window_management
Tried again on the Samsung Tab S7 and the Pixel 4a. It looks fine during startup/initialization.
The Pixel 4a OpenGLES has other rendering issues; the 2D scene (UI) fades out after switching back and forth several times.
@Alex2782 I'm seeing the same issue on a Samsung Tab S8 when using the OpenGL renderer. I'll create a bug for the rendering team. |
a72586f to
3d8c372
Compare
The issue is also reproducible on 4.4.1-stable after disabling the feature check, so it should not be a blocker for this PR: func _on_transparent_check_button_toggled(button_pressed: bool) -> void:
#if not DisplayServer.has_feature(DisplayServer.FEATURE_WINDOW_TRANSPARENCY):
# OS.alert("Window transparency is not supported by the current display server (%s)." % DisplayServer.get_name())
# return
get_viewport().transparent_bg = button_pressed
DisplayServer.window_set_flag(DisplayServer.WINDOW_FLAG_TRANSPARENT, button_pressed)
Screen_Recording_20250529_090905_Window.Management.mp4 |
|
I am running the demo directly from Android Editor and having the same issue in opengl renderer but also having issues in vulkan renderer. Notice that after toggled off Screenrecorder-2025-05-29-23-00-53-465.mp4 |
There was a problem hiding this comment.
This should be set at runtime, if window transparent flag changes in Godot.
3d8c372 to
547450b
Compare
|
Thanks! |
Updates the logic to detect when transparency is required on Android using
display/window/per_pixel_transparency/allowed,display/window/size/transparent, andrendering/viewport/transparent_background, which updates the render view configuration and the app's theme.The requirement to update the app's theme means the feature is only available to
gradlebuild exports.Fixes #106703
Before
Screen_Recording_20250522_001406_GLTF.Viewer.mp4
After
Screen_Recording_20250522_001458_GLTF.Viewer.mp4