Thread 0 crashed with ARM Thread State (64-bit)

My app is rejected from iOS review.

And It says that app crashed in only iPad.

I test with iPhone and iPad (5th generation) same as tested device in review, it works fine.

But I can't read crash report.

Can you give me some advice regarding what makes my app crash only in iPad?

I just suspect that I remove some cache in resume cycle of flutter app in main.dart.

@override
  void deactivate() {
    removeDiaryRankingCache();
    super.deactivate();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    super.didChangeAppLifecycleState(state);

    if (state == AppLifecycleState.resumed) {
      updateLastVisit();
      removeDiaryRankingCache();
    }
  }

And this removeDiaryRankingCache() takes so much time and it is over allocated time to launch app in iPad or use so much memory over allocated storage of iPad..?

Please help me in any way.

Answered by DTS Engineer in 801560022
Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: FRONTBOARD 2343432205 
:20314 exhausted real (wall clock) time allowance of 19.65 seconds
ProcessVisibility: Foreground
ProcessState: Running
WatchdogEvent: scene-create
WatchdogVisibility: Foreground
WatchdogCPUStatistics: (
"Elapsed total CPU time (seconds): 96.850 (user 64.490, system 32.360), 59% CPU",
"Elapsed application CPU time (seconds): 0.316, 0% CPU"
) reportType:CrashLog maxTerminationResistance:Interactive>

2343432205 is the decimal representation of the 0x8badf00d termination code, which means your app took too long to launch. 0% CPU by your app means you're waiting on a system resource.

7   LocationSupport               	       0x1b782a818 CLConnection::sendMessageSync(std::__1::shared_ptr, bool) + 168
8   LocationSupport               	       0x1b782a708 CLConnectionClient::sendMessageSync(std::__1::shared_ptr, bool) + 120
9   CoreMotion                    	       0x1a51f5830 0x1a4e31000 + 3950640
10  CoreMotion                    	       0x1a51f571c 0x1a4e31000 + 3950364
11  CoreMotion                    	       0x1a51f613c 0x1a4e31000 + 3952956
12  CoreMotion                    	       0x1a4e41650 0x1a4e31000 + 67152
13  CoreMotion                    	       0x1a4e33f1c 0x1a4e31000 + 12060
14  pedometer                     	       0x105efcd68 @objc StepDetector.init() + 92
15  pedometer                     	       0x105efce74 specialized static SwiftPedometerPlugin.register(with:) + 52
16  pedometer                     	       0x105efc050 @objc static SwiftPedometerPlugin.register(with:) + 32
17  Runner                        	       0x104488588 +[GeneratedPluginRegistrant registerWithRegistry:] (in Runner) (GeneratedPluginRegistrant.m:258) + 34184
18  Runner                        	       0x1044888b8 AppDelegate.application(_:didFinishLaunchingWithOptions:) (in Runner) (AppDelegate.swift:14) + 35000

The top few frames here look like you're waiting on a system resource in relation to permission to access privacy-sensitive data, such as location or motion. However, the bottom frames show that your app hasn't even finished the full launch process yet before requesting such permissions. Since your app hasn't finished launching yet, this is way too early, as you don't even have your app UI up and running at this point in the launch yet. Further, requesting permissions right at launch (even at a launch point later than this) is rarely the right choice. The Human Interface Guidelines have information on when to request permission to guide your users to why you need such permissions.

—Ed Ford,  DTS Engineer

Accepted Answer
Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: FRONTBOARD 2343432205 
:20314 exhausted real (wall clock) time allowance of 19.65 seconds
ProcessVisibility: Foreground
ProcessState: Running
WatchdogEvent: scene-create
WatchdogVisibility: Foreground
WatchdogCPUStatistics: (
"Elapsed total CPU time (seconds): 96.850 (user 64.490, system 32.360), 59% CPU",
"Elapsed application CPU time (seconds): 0.316, 0% CPU"
) reportType:CrashLog maxTerminationResistance:Interactive>

2343432205 is the decimal representation of the 0x8badf00d termination code, which means your app took too long to launch. 0% CPU by your app means you're waiting on a system resource.

7   LocationSupport               	       0x1b782a818 CLConnection::sendMessageSync(std::__1::shared_ptr, bool) + 168
8   LocationSupport               	       0x1b782a708 CLConnectionClient::sendMessageSync(std::__1::shared_ptr, bool) + 120
9   CoreMotion                    	       0x1a51f5830 0x1a4e31000 + 3950640
10  CoreMotion                    	       0x1a51f571c 0x1a4e31000 + 3950364
11  CoreMotion                    	       0x1a51f613c 0x1a4e31000 + 3952956
12  CoreMotion                    	       0x1a4e41650 0x1a4e31000 + 67152
13  CoreMotion                    	       0x1a4e33f1c 0x1a4e31000 + 12060
14  pedometer                     	       0x105efcd68 @objc StepDetector.init() + 92
15  pedometer                     	       0x105efce74 specialized static SwiftPedometerPlugin.register(with:) + 52
16  pedometer                     	       0x105efc050 @objc static SwiftPedometerPlugin.register(with:) + 32
17  Runner                        	       0x104488588 +[GeneratedPluginRegistrant registerWithRegistry:] (in Runner) (GeneratedPluginRegistrant.m:258) + 34184
18  Runner                        	       0x1044888b8 AppDelegate.application(_:didFinishLaunchingWithOptions:) (in Runner) (AppDelegate.swift:14) + 35000

The top few frames here look like you're waiting on a system resource in relation to permission to access privacy-sensitive data, such as location or motion. However, the bottom frames show that your app hasn't even finished the full launch process yet before requesting such permissions. Since your app hasn't finished launching yet, this is way too early, as you don't even have your app UI up and running at this point in the launch yet. Further, requesting permissions right at launch (even at a launch point later than this) is rarely the right choice. The Human Interface Guidelines have information on when to request permission to guide your users to why you need such permissions.

—Ed Ford,  DTS Engineer

Thanks for your help to read crash log.

Now my app has rejected over 2weeks due to this crash log.

And this crash happens when app is on launch only on iPad.

When I testd iPad simulators and iPhones, they were successfully launched.

I look into main.dart code at first based on that.

main.dart

void main() async {
  await runZonedGuarded(() async {
    try {
      WidgetsFlutterBinding.ensureInitialized();

      await dotenv.load(fileName: ".env");
      KakaoSdk.init(nativeAppKey: dotenv.env["KAKAO_NATIVE_APP_KEY"]);

      if (Firebase.apps.isEmpty) {
        await Firebase.initializeApp(
          options: DefaultFirebaseOptions.currentPlatform,
        );
      }

      await Supabase.initialize(
        url: dotenv.env["SUPABASE_URL"]!,
        anonKey: dotenv.env["SUPABASE_ANONKEY"]!,
      );

      await SystemChrome.setPreferredOrientations([
        DeviceOrientation.portraitUp,
      ]);

      await StepNotification().initializeService();
      FirebaseMessaging.onBackgroundMessage(messagingBackgroundHandler);

      if (Platform.isAndroid) {
        await AndroidAlarmManager.initialize();
        await AndroidAlarmManager.periodic(
          const Duration(hours: 8),
          10,
          stepAlarmManager,
          allowWhileIdle: true,
          wakeup: true,
          rescheduleOnReboot: true,
        );
      }
    } catch (e) {
      // ignore: avoid_print
      print("initialize app: $e");
    }

    if (kDebugMode) {
      runApp(
        const riverpod.ProviderScope(
          child: OnldoccFlutterApp(),
        ),
      );
    } else {
      final dnsCode = dotenv.env["SENTRY_DNS"];
      await SentryFlutter.init(
        (options) {
          options.dsn = dnsCode;
          options.attachStacktrace = true;
        },
        appRunner: () => runApp(
          const riverpod.ProviderScope(
            child: OnldoccFlutterApp(),
          ),
        ),
      );
    }
  }, (exception, stackTrace) async {
    Sentry.captureException(exception, stackTrace: stackTrace);
  });
}

The only code regarding package pedometer is StepNotification().initializeService(); from main.dart.

So I moved code StepNotification().initializeService(); that initialize process to count user's step into another part of app for test and submit this app.

But that app is also rejected with same issue.

[PS]

StepNotification().initializeService() initialized flutter_background_service and after user chooses to start background service, pedometer package will be initialized.

Since I already tested as moving this to another part, I guess that this line is not causing error.

And even this line also don't initialize package pedometer at the moment when app is on launch.

I look into AppDelegate.swift code on next.

AppDelegate.swift

import UIKit
import Flutter
import flutter_background_service_ios

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    SwiftFlutterBackgroundServicePlugin.taskIdentifier = "dev.flutter.background.refresh"
    
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

I think when GeneratedPluginRegistrant.register(with: self) is executed, all packages request corresponding permission before didFinishLaunchingWithOptions step and it takes long time.

But It's also weird that before 2weeks, I haven't get rejected from app review with this issue even though AppDelegate.swift code is same.

I don't know why this error happens suddenly even only on iPad that iOS test team uses.

And I also check that permission 'notification' that is used from other packages is also requested before app is launched (white blank screen before UX is drawn) even when I successfully launch my app.

Why permissions are requested before app is launched even though I don't make it that.

I think when GeneratedPluginRegistrant.register(with: self) is executed, all packages request corresponding permission before didFinishLaunchingWithOptions step and it takes long time.

I can't speak to any specifics about your environment based on a vendor's framework, but you should investigate how you can ask for permission to privacy-sensitive data at an opportune time in your app, rather than only at launch, per my prior information about the Human Interface Guidelines.

— Ed Ford,  DTS Engineer

Thread 0 crashed with ARM Thread State (64-bit)
 
 
Q