ios: fix isLowerPowerModeEnabled deadlock crash #94
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
iOS 15.x (I think up to 15.2) crashes due to a deadlock when the following situation occurs:
ProcessInfo.processInfo.isLowPowerModeEnabled
Notification.Name.NSProcessInfoPowerStateDidChange
notification in a synchronous way from withinisLowePowerModeEnabled
getter.ProcessInfo.processInfo.isLowPowerModeEnabled
from withinNotification.Name.NSProcessInfoPowerStateDidChange
notification.The issue is caused by a bug in iOS 15 (which was fixed in later releases), so there is no perfect solution for this. My approach minimizes the risk of a crash by reducing the number of times we access
ProcessInfo.processInfo.isLowPowerModeEnabled
by over 99%. In practice, this should resolve the issue that our customers experienced.One thing to note: I confirmed that this crash does not always occur on the first access of the
ProcessInfo.processInfo.isLowPowerModeEnabled
property.Fixes BIT-4031
Stacktrace: