4

With the release of iOS 15, a new behavior was introduced called 'prewarming' where certain processes can execute an indeterminate amount of time before the user interacts with the app. That behavior is described here.

A consequence of this is that some OS-specific resources (such as keychain) are not necessarily available during this phase, as noted in this article.

My question is - does this prewarming phase trigger a lifecycle change in Flutter that is enumerated here?

Additionally, does there exist a similar behavior in Android?

Daniel Allen
  • 894
  • 1
  • 10
  • 23

1 Answers1

0

This is no definitive answer, and I'd be happy if someone could provide further info, but as far as I can tell there is no callback to check this.

The following is tested with an app where iOS triggers prewarming upon receival of a push notification - either with locked or unlocked screen. When adding a WidgetsBindingObserver first things first in the main() function, this observer's didChangeAppLifecycleState fires with AppLifecycleState.inactive when prewarming begins (independently of whether the screen is locked or not when prewarming). But it does the same on a normal app start, except then soon after a resumed state is received as well.

It seems that some things can interrupt prewarming, like a await Future.delayed(Duration(seconds: 2)); or a runApp(SomePointlessWidget());.

Also note that when depending on the Keychain in your initializations, contents can be unavailable (when prewarming is triggered while the screen is locked) and you could, for example, check by writing and reading a dummy variable whether the Keychain is available. Because callbacks like applicationProtectedDataDidBecomeAvailable: seem to be unavailable in flutter, cf. this PR: https://github.com/flutter/flutter/pull/9818 (see also https://github.com/flutter/flutter/issues/9682).

jakobleck
  • 43
  • 8