Skip to content

Commit

Permalink
Merge pull request #1514 from bugsnag/PLAT-9367-thermal-state-workaround
Browse files Browse the repository at this point in the history
Plat 9367 thermal state workaround
  • Loading branch information
kstenerud authored Jan 11, 2023
2 parents 8f89a59 + fd4851c commit 68b51af
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Bugsnag/Helpers/BSGRunContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,16 @@ static void NoteThermalState(__unused CFNotificationCenterRef center,
__unused CFNotificationName name,
const void *object,
__unused CFDictionaryRef userInfo) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
bsg_runContext->thermalState = ((__bridge NSProcessInfo *)object).thermalState;
#pragma clang diagnostic pop
BSGRunContextUpdateTimestamp();
if (@available(iOS 11.0, tvOS 11.0, watchOS 4.0, *)) {
// Workaround for iOS 15.0.2 to 15.1.1: Foundation in rare cases posts
// ThermalStateDidChangeNotification from within -[NSProcessInfo thermalState],
// causing recursion and a crash via _os_unfair_lock_recursive_abort().
// To avoid this, grab the new thermal state asynchronously.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
bsg_runContext->thermalState = ((__bridge NSProcessInfo *)object).thermalState;
BSGRunContextUpdateTimestamp();
});
}
}

#if BSG_HAVE_OOM_DETECTION
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
=========

## TBD

### Bug fixes

* Workaround for thermal state lock re-entry bug on iOS 15.0.2-15.1.1.
[1514]https://github.com/bugsnag/bugsnag-cocoa/pull/1514

* Clean up compiler warnings about data races and nullability.
[1515](https://github.com/bugsnag/bugsnag-cocoa/pull/1515)

## 6.25.1 (2022-12-07)

### Bug fixes
Expand Down

0 comments on commit 68b51af

Please sign in to comment.