Skip to content

Commit 805cb6e

Browse files
committed
trying to fix smth for Android and make the log for message box under SDL_PLATFORM_IOS
1 parent 95528d9 commit 805cb6e

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

project/lib/sdl/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,19 @@ public static void handleNativeState() {
845845

846846
// Try a transition to resumed state
847847
if (mNextNativeState == NativeState.RESUMED) {
848+
// Recover mIsSurfaceReady when returning from startActivityForResult (e.g. Android Settings
849+
// for MANAGE_APP_ALL_FILES_ACCESS) — surfaceChanged() may not re-fire even though the
850+
// surface is still physically valid, leaving the resume gate permanently blocked.
851+
if (!mSurface.mIsSurfaceReady && mIsResumedCalled && (mHasFocus || mHasMultiWindow)) {
852+
try {
853+
if (mSurface.getHolder().getSurface().isValid()) {
854+
Log.v(TAG, "handleNativeState: surface valid but mIsSurfaceReady=false, recovering");
855+
mSurface.mIsSurfaceReady = true;
856+
}
857+
} catch (Exception e) {
858+
// Surface not yet available — leave mIsSurfaceReady as-is
859+
}
860+
}
848861
if (mSurface.mIsSurfaceReady && (mHasFocus || mHasMultiWindow) && mIsResumedCalled) {
849862
if (mSDLThread == null) {
850863
// This is the entry point to the C app.

project/lib/sdl/src/video/SDL_video.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6005,7 +6005,9 @@ bool SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
60056005

60066006
SDL_ClearError();
60076007

6008+
#if SDL_PLATFORM_IOS
60086009
SDL_Log("SDL_ShowMessageBox: \"%s\" - \"%s\"", messageboxdata->title, messageboxdata->message);
6010+
#endif
60096011

60106012
if (_this && _this->ShowMessageBox) {
60116013
result = _this->ShowMessageBox(_this, messageboxdata, buttonID);

templates/android/template/app/src/main/java/org/libsdl/app/SDLActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,19 @@ public static void handleNativeState() {
849849

850850
// Try a transition to resumed state
851851
if (mNextNativeState == NativeState.RESUMED) {
852+
// Recover mIsSurfaceReady when returning from startActivityForResult (e.g. Android Settings
853+
// for MANAGE_APP_ALL_FILES_ACCESS) — surfaceChanged() may not re-fire even though the
854+
// surface is still physically valid, leaving the resume gate permanently blocked.
855+
if (!mSurface.mIsSurfaceReady && mIsResumedCalled && (mHasFocus || mHasMultiWindow)) {
856+
try {
857+
if (mSurface.getHolder().getSurface().isValid()) {
858+
Log.v(TAG, "handleNativeState: surface valid but mIsSurfaceReady=false, recovering");
859+
mSurface.mIsSurfaceReady = true;
860+
}
861+
} catch (Exception e) {
862+
// Surface not yet available — leave mIsSurfaceReady as-is
863+
}
864+
}
852865
if (mSurface.mIsSurfaceReady && (mHasFocus || mHasMultiWindow) && mIsResumedCalled) {
853866
if (mSDLThread == null) {
854867
// This is the entry point to the C app.

0 commit comments

Comments
 (0)