Skip to content

Commit

Permalink
Fix crash accessing Choreographer instance (#2970)
Browse files Browse the repository at this point in the history
* choreographer instance is now retrieved in a try/catch block, due to a crash reported by Google Play SDK console
  • Loading branch information
stefanosiano committed Oct 11, 2023
1 parent f02ae03 commit 4bf95dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

- Always attach OkHttp errors and Http Client Errors only to call root span ([#2961](https://github.com/getsentry/sentry-java/pull/2961))

### Fixes

- Fixed crash accessing Choreographer instance ([#2970](https://github.com/getsentry/sentry-java/pull/2970))

## 6.30.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,20 @@ public SentryFrameMetricsCollector(
// https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:metrics/metrics-performance/src/main/java/androidx/metrics/performance/JankStatsApi24Impl.kt

// The Choreographer instance must be accessed on the main thread
new Handler(Looper.getMainLooper()).post(() -> choreographer = Choreographer.getInstance());
new Handler(Looper.getMainLooper())
.post(
() -> {
try {
choreographer = Choreographer.getInstance();
} catch (Throwable e) {
options
.getLogger()
.log(
SentryLevel.ERROR,
"Error retrieving Choreographer instance. Slow and frozen frames will not be reported.",
e);
}
});
// Let's get the last frame timestamp from the choreographer private field
try {
choreographerLastFrameTimeField = Choreographer.class.getDeclaredField("mLastFrameTimeNanos");
Expand Down

0 comments on commit 4bf95dd

Please sign in to comment.