mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Android: Fix rotating EmulationActivity after boot fails
Time for yet another new iteration of working around the "surface destruction during boot" problem... This time, the strategy is to use a mutex in MainAndroid.cpp.
This commit is contained in:
@ -403,15 +403,13 @@ public final class NativeLibrary
|
||||
*/
|
||||
public static native void StopEmulation();
|
||||
|
||||
public static native boolean IsBooting();
|
||||
|
||||
public static native void WaitUntilDoneBooting();
|
||||
|
||||
/**
|
||||
* Returns true if emulation is running (or is paused).
|
||||
*/
|
||||
public static native boolean IsRunning();
|
||||
|
||||
public static native boolean IsRunningAndStarted();
|
||||
|
||||
/**
|
||||
* Enables or disables CPU block profiling
|
||||
*
|
||||
@ -487,7 +485,7 @@ public final class NativeLibrary
|
||||
private static native String GetCurrentTitleDescriptionUnchecked();
|
||||
|
||||
public static boolean displayAlertMsg(final String caption, final String text,
|
||||
final boolean yesNo, final boolean isWarning)
|
||||
final boolean yesNo, final boolean isWarning, final boolean nonBlocking)
|
||||
{
|
||||
Log.error("[NativeLibrary] Alert: " + text);
|
||||
final EmulationActivity emulationActivity = sEmulationActivity.get();
|
||||
@ -498,10 +496,9 @@ public final class NativeLibrary
|
||||
}
|
||||
else
|
||||
{
|
||||
// AlertMessages while the core is booting will deadlock if WaitUntilDoneBooting is called.
|
||||
// We also can't use AlertMessages unless we have a non-null activity reference.
|
||||
// As a fallback, we use toasts instead.
|
||||
if (emulationActivity == null || IsBooting())
|
||||
// We can't use AlertMessages unless we have a non-null activity reference
|
||||
// and are allowed to block. As a fallback, we can use toasts.
|
||||
if (emulationActivity == null || nonBlocking)
|
||||
{
|
||||
new Handler(Looper.getMainLooper()).post(
|
||||
() -> Toast.makeText(DolphinApplication.getAppContext(), text, Toast.LENGTH_LONG)
|
||||
|
@ -330,16 +330,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
||||
mSurface = null;
|
||||
Log.debug("[EmulationFragment] Surface destroyed.");
|
||||
|
||||
if (state != State.STOPPED && !NativeLibrary.IsShowingAlertMessage())
|
||||
{
|
||||
// In order to avoid dereferencing nullptr, we must not destroy the surface while booting
|
||||
// the core, so wait here if necessary. An easy (but not 100% consistent) way to reach
|
||||
// this method while the core is booting is by having landscape orientation lock enabled
|
||||
// and starting emulation while the phone is in portrait mode, leading to the activity
|
||||
// being recreated very soon after NativeLibrary.Run has been called.
|
||||
NativeLibrary.WaitUntilDoneBooting();
|
||||
}
|
||||
|
||||
NativeLibrary.SurfaceDestroyed();
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
|
||||
public void initTouchPointer()
|
||||
{
|
||||
// Check if we have all the data we need yet
|
||||
boolean aspectRatioAvailable = NativeLibrary.IsRunning() && !NativeLibrary.IsBooting();
|
||||
boolean aspectRatioAvailable = NativeLibrary.IsRunningAndStarted();
|
||||
if (!aspectRatioAvailable || mSurfacePosition == null)
|
||||
return;
|
||||
|
||||
|
Reference in New Issue
Block a user