1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Android: Stabilize camera lifecycle handling

- Pause camera feeds during lifecycle transitions to avoid crashes
- Refresh camera metadata after rotation to keep orientation accurate
This commit is contained in:
KOGA Mitsuhiro
2025-10-21 07:35:54 +09:00
parent 9cd297b6f2
commit 4483871cd3
6 changed files with 284 additions and 29 deletions

View File

@@ -170,6 +170,7 @@ class Godot private constructor(val context: Context) {
*/
private var renderViewInitialized = false
private var primaryHost: GodotHost? = null
private var currentConfig = context.resources.configuration
/**
* Tracks whether we're in the RESUMED lifecycle state.
@@ -757,6 +758,13 @@ class Godot private constructor(val context: Context) {
darkMode = newDarkMode
GodotLib.onNightModeChanged()
}
if (currentConfig.orientation != newConfig.orientation) {
runOnRenderThread {
GodotLib.onScreenRotationChange()
}
}
currentConfig = newConfig
}
/**

View File

@@ -295,6 +295,11 @@ public class GodotLib {
*/
public static native void onRendererPaused();
/**
* Invoked when the screen orientation changes.
*/
static native void onScreenRotationChange();
/**
* @return true if input must be dispatched from the render thread. If false, input is
* dispatched from the UI thread.