Skip to content
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

iOS 16 crashing upon Pause and Resume #702

Open
andybass opened this issue Oct 18, 2022 · 4 comments
Open

iOS 16 crashing upon Pause and Resume #702

andybass opened this issue Oct 18, 2022 · 4 comments
Labels
bug This issue refers to a bug in the plugin ios This issue is specific to the iOS/iPadOS Platform. more info wanted This issue means we need more info to help

Comments

@andybass
Copy link

Currently, within my onUnityCreated callback, I'm calling controller.pause(), then controller.resume() to ensure Unity is ready to go (not doing this prevents messages from passing properly to Unity).

Up until iOS 16, this was working properly. But, now the call to Pause crashes the app. I've included the stack trace from Xcode below.

I've tried both stable and master channels of Flutter, as well as 2020.3.25f1 and 2021.3.11f1 versions of Unity - with no difference.

--

Hardware Model: iPhone15,2
Process: Runner [2646]
Path: /private/var/containers/Bundle/Application/13B32700-8961-4EEE-8AA3-2C6979ED7EB6/Runner.app/Runner
Identifier: com.Saganworks.SaganworksTest
Version: 1.34 (1)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.Saganworks.SaganworksTest [1052]

Date/Time: 2022-10-18 13:14:29.7559 -0400
Launch Time: 2022-10-18 13:14:28.8858 -0400
OS Version: iPhone OS 16.1 (20B5072b)
Release Type: Beta
Baseband Version: 1.13.02
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x000000000000005d
Exception Codes: 0x0000000000000001, 0x000000000000005d
VM Region Info: 0x5d is not in any region. Bytes before following region: 68719476643
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
commpage (reserved) 1000000000-7000000000 [384.0G] ---/--- SM=NUL ...(unallocated)
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [2646]

Triggered by Thread: 0

Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 UnityFramework 0x101d581a0 AudioManager::SetApplicationPause(bool) + 0
1 UnityFramework 0x101b37f48 SetPlayerPause(PlayerPause, bool) + 184
2 UnityFramework 0x10206d728 UnityPause + 140
3 flutter_unity_widget 0x1083ee850 FLTUnityWidgetController.methodHandler(_:result:) + 1700
4 flutter_unity_widget 0x1083f0d54 partial apply for implicit closure #2 in implicit closure #1 in FLTUnityWidgetController.init(frame:viewIdentifier:arguments:registrar:) + 20
5 flutter_unity_widget 0x1083f0d98 partial apply for thunk for @escaping @callee_guaranteed (@guaranteed FlutterMethodCall, @unowned @callee_guaranteed (@in_guaranteed Any?) -> ()) -> () + 20
6 flutter_unity_widget 0x1083ee0a4 thunk for @escaping @callee_guaranteed (@guaranteed FlutterMethodCall, @guaranteed @escaping @callee_guaranteed (@in_guaranteed Any?) -> ()) -> () + 108
7 Flutter 0x108a4c9e4 0x1084d4000 + 5736932
8 Flutter 0x10851968c 0x1084d4000 + 284300
9 libdispatch.dylib 0x19a3f04b4 _dispatch_call_block_and_release + 32
10 libdispatch.dylib 0x19a3f1fdc _dispatch_client_callout + 20
11 libdispatch.dylib 0x19a4007f4 _dispatch_main_queue_drain + 928
12 libdispatch.dylib 0x19a400444 _dispatch_main_queue_callback_4CF + 44
13 CoreFoundation 0x192eae6f8 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 16
14 CoreFoundation 0x192e90058 __CFRunLoopRun + 2036
15 CoreFoundation 0x192e94ed4 CFRunLoopRunSpecific + 612
16 GraphicsServices 0x1cc0ca368 GSEventRunModal + 164
17 UIKitCore 0x195379028 -[UIApplication _run] + 888
18 UIKitCore 0x195378c8c UIApplicationMain + 340
19 Runner 0x10066c9e4 main + 64
20 dyld 0x1b14a5960 start + 2528

@timbotimbo
Copy link
Collaborator

Does the same happen if you pause or resume outside of that callback?
I pause and resume Unity in Flutter's didChangeAppLifecycleState(AppLifecycleState state), and that doesn't seem to crash on iOS 16.

I've had other new crashes unique to iOS 16, but those don't seem to match your trace. (I needed to disable Xcode thread performance checker, and Unity iOS multithreaded rendering)

@akhil-tlm-sg
Copy link

+1 @juicycleff tagging you to bring this to your notice.
I am able to reproduce this as well

@akhil-tlm-sg
Copy link

@timbotimbo can you please provide a little more detail on how you are doing the pause and resume in the lifecycle events instead of the unitycreated callback ?

There are other issues which require me to do the pause and resume on the oncreated for the rest of the functionality to work well and now the app crashes randomly

@timbotimbo
Copy link
Collaborator

Sorry for the slow response, I lost track of this one.

This is basically the setup that my app was using before, and I haven't had this crash on iOS 16 yet.

@override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    if (state == AppLifecycleState.inactive ||
        state == AppLifecycleState.paused ||
        state == AppLifecycleState.detached) {
      unityViewController?.pause();
    } else if (state == AppLifecycleState.resumed) {
      unityViewController?.resume();
    }
  }
  
  void onUnityViewCreated(UnityWidgetController? controller) {
    unityViewController = controller;
    
    //send message to unity to switch scene
  }

You both talk about other issues that require pause and resume in the onCreated, but I'm not aware of any.
This setup receives messages just fine for me on plugin version 2022.2.0.

@timbotimbo timbotimbo added bug This issue refers to a bug in the plugin ios This issue is specific to the iOS/iPadOS Platform. more info wanted This issue means we need more info to help labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue refers to a bug in the plugin ios This issue is specific to the iOS/iPadOS Platform. more info wanted This issue means we need more info to help
Projects
None yet
Development

No branches or pull requests

3 participants