CarnegieTechnologies / gallery_saver

Flutter plugin that saves images and videos to devices gallery
Apache License 2.0
157 stars 328 forks source link

Ungraceful iOS Crash on Debug homescreen launch #173

Open machty opened 2 years ago

machty commented 2 years ago

If you build iOS from VSCode or from XCode, and then you close the debug session and try to start the app by tapping the icon from the homescreen, you'll see a message that says:

In iOS 14+, debug mode Flutter apps can only be launched from Flutter tooling, IDEs with Flutter plugins or from Xcode. Alternatively, build in profile or release modes to enable launching from the home screen.

Because I'm new to Flutter, it's easy to forget this limitation, but for some reason, if I have the GallerySaver plugin installed, instead of displaying the above helpful message, the app crashes in some GallerySaver initialization code. It seems to be in SwiftGallerySaverPlugin.register, and I believe registrar is null even though it's suppose to be non-nullable. If I remove GallerySaver as a plugin, I avoid this crash and get the helpful white message instead.

Here is the GeneratedPluginRegistrant, demonstrating that there are other plugins that don't seem to have this issue:

+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
  [CameraPlugin registerWithRegistrar:[registry registrarForPlugin:@"CameraPlugin"]];
  [FFmpegKitFlutterPlugin registerWithRegistrar:[registry registrarForPlugin:@"FFmpegKitFlutterPlugin"]];
  [FLTFirebaseAnalyticsPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTFirebaseAnalyticsPlugin"]];
  [FLTFirebaseCorePlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTFirebaseCorePlugin"]];
  [FLTFirebaseCrashlyticsPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTFirebaseCrashlyticsPlugin"]];
  [FLTFirebaseMessagingPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTFirebaseMessagingPlugin"]];
  [GallerySaverPlugin registerWithRegistrar:[registry registrarForPlugin:@"GallerySaverPlugin"]];
  [FLTPathProviderPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTPathProviderPlugin"]];
  [FLTVideoPlayerPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTVideoPlayerPlugin"]];
}

I'm not sure what might be different/special about GallerySaver, but it'd be worth fixing this just to minimize confusion for the new devs.

Crash Log ``` Incident Identifier: BB7B591D-2356-4CCE-A082-B0E8C5180BB3 CrashReporter Key: d3965fddd11b1227023848cfb76d5f3a5f6c2804 Hardware Model: iPhone10,1 Process: Runner [1148] Path: /private/var/containers/Bundle/Application/D1F80E17-358E-4B3B-B458-E6816A210991/Runner.app/Runner Identifier: com.machty.sliceanddice Version: 1.0.0 (1) Code Type: ARM-64 (Native) Role: Foreground Parent Process: launchd [1] Coalition: com.machty.sliceanddice [850] Date/Time: 2021-12-26 22:45:12.5894 -0500 Launch Time: 2021-12-26 22:45:12.1341 -0500 OS Version: iPhone OS 15.1 (19B74) Release Type: User Baseband Version: 7.02.00 Report Version: 104 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000 Exception Codes: 0x0000000000000001, 0x0000000000000000 VM Region Info: 0 is not in any region. Bytes before following region: 4337827840 REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL UNUSED SPACE AT START ---> __TEXT 1028e0000-103828000 [ 15.3M] r-x/r-x SM=COW ...er.app/Runner Exception Note: EXC_CORPSE_NOTIFY Termination Reason: SIGNAL; [11] Terminating Process: exc handler [1148] Terminating Process: exc handler [1148] Triggered by Thread: 0 Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 libswiftCore.dylib 0x18741e1a0 swift_getObjectType + 36 1 gallery_saver 0x10450cce8 static SwiftGallerySaverPlugin.register(with:) + 108 2 gallery_saver 0x10450cce8 static SwiftGallerySaverPlugin.register(with:) + 108 3 gallery_saver 0x10450cedc @objc static SwiftGallerySaverPlugin.register(with:) + 56 4 gallery_saver 0x10450c984 +[GallerySaverPlugin registerWithRegistrar:] + 76 5 Runner 0x1028e7a98 +[GeneratedPluginRegistrant registerWithRegistry:] + 280 6 Runner 0x1028e7bc0 AppDelegate.application(_:didFinishLaunchingWithOptions:) + 112 7 Runner 0x1028e7e6c @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) + 184 8 UIKitCore 0x18504d36c -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 352 9 UIKitCore 0x1852236d8 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 3456 10 UIKitCore 0x18520c8c0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1216 11 UIKitCore 0x185079700 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 148 12 UIKitCore 0x184ede02c _UIScenePerformActionsWithLifecycleActionMask + 96 13 UIKitCore 0x185001b24 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 196 ```
flutter doctor - v [✓] Flutter (Channel stable, 2.8.1, on macOS 11.5.2 20G95 darwin-x64, locale en-US) • Flutter version 2.8.1 at /Users/machty/code/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 77d935af4d (11 days ago), 2021-12-16 08:37:33 -0800 • Engine revision 890a5fca2e • Dart version 2.15.1 [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /Users/machty/Library/Android/sdk • Platform android-31, build-tools 29.0.2 • ANDROID_HOME = /Users/machty/Library/Android/sdk • ANDROID_SDK_ROOT = /Users/machty/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2020.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) [✓] VS Code (version 1.63.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.29.0 [✓] Connected device (2 available) • Alex’s fone (mobile) • acf5ce666f195e3e323b04493dd4e6e8ad24e89e • ios • iOS 15.1 19B74 • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110 • No issues found!