feat: ANR (Android) and hang detection (iOS) reporting#122
Open
bobbyg603 wants to merge 2 commits into
Open
Conversation
Both features already exist in the native libraries; this wires them up. Android — ANR: - Update bugsplat-android-release.aar to v1.3.0 (built from the v1.3.0 tag). - ANR detection is automatic inside BugSplatBridge.initBugSplat(...); reports arrive as Android.ANR. Requires Android 11+ at runtime. - Active when UseNativeCrashReportingForAndroid is enabled. iOS — fatal hang detection: - Update BugSplat.xcframework and BugSplat-macOS.dylib to bugsplat-apple v3.2.0. - Set enableHangDetection in the iOS bridge before [BugSplat start], coupled to UseNativeCrashReportingForIos. Reports arrive as App Hang (Fatal). - macOS hang detection intentionally left off for now. Sample: - Add Event_HangNative() and a Hang/ANR button. - _hangNativeIos() shows a confirmation alert then blocks the main thread with NSThread sleepUntilDate:, matching the bugsplat-apple example. - Flatten crash buttons to direct On Click wiring; retire the unused ForcedCrashEvent relay. Docs/version: - Document ANR and hang detection in README. - Bump package version to 4.1.0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR wires up ANR reporting on Android and fatal main-thread hang detection on iOS by updating the bundled native libraries and exposing sample/test hooks + documentation.
Changes:
- Added native hang/ANR trigger path in the Unity sample (new “Hang: Native” button +
Event_HangNative()). - Enabled iOS hang detection in the ObjC bridge before starting BugSplat.
- Documented ANR + hang detection and bumped the package version to 4.1.0.
Reviewed changes
Copilot reviewed 16 out of 36 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Samples~/my-unity-crasher/Scripts/ForcedCrashEvent.cs.meta | Removes the old relay script meta (no longer used by the sample). |
| Samples~/my-unity-crasher/Scripts/ForcedCrashEvent.cs | Removes the old relay script in favor of direct button wiring. |
| Samples~/my-unity-crasher/Scripts/ErrorGenerator.cs | Adds Event_HangNative() + platform-specific native hang triggers. |
| Samples~/my-unity-crasher/Scenes/Sample.unity | Updates sample scene UI wiring and adds a Hang/ANR button instance. |
| Samples~/my-unity-crasher/Prefabs/Button_ForceCrash.prefab | Updates the shared button prefab structure after removing the relay component. |
| README.md | Documents Android ANR reporting and iOS fatal hang detection behavior. |
| package.json | Bumps Unity package version to 4.1.0. |
| Editor/IOS/ObjC/BugSplatBridge.mm | Enables hang detection before [BugSplat start] and adds an iOS hang test hook with a confirmation alert. |
| Editor/IOS/Frameworks/BugSplat.xcframework/tvos-arm64/BugSplat.framework/Headers/BugSplat.h | Updates vendored BugSplat headers (adds hang detection API). |
| Editor/IOS/Frameworks/BugSplat.xcframework/tvos-arm64_x86_64-simulator/BugSplat.framework/Headers/BugSplat.h | Updates vendored BugSplat headers (adds hang detection API). |
| Editor/IOS/Frameworks/BugSplat.xcframework/tvos-arm64_x86_64-simulator/BugSplat.framework/_CodeSignature/CodeResources | Updates framework code signature resources after header changes. |
| Editor/IOS/Frameworks/BugSplat.xcframework/macos-arm64_x86_64/BugSplat.framework/Versions/A/Headers/BugSplat.h | Updates vendored BugSplat headers for macOS slice (hang detection API present). |
| Editor/IOS/Frameworks/BugSplat.xcframework/ios-arm64/BugSplat.framework/Headers/BugSplat.h | Updates vendored BugSplat headers (adds hang detection API). |
| Editor/IOS/Frameworks/BugSplat.xcframework/ios-arm64_x86_64-simulator/BugSplat.framework/Headers/BugSplat.h | Updates vendored BugSplat headers (adds hang detection API). |
| Editor/IOS/Frameworks/BugSplat.xcframework/ios-arm64_x86_64-simulator/BugSplat.framework/_CodeSignature/CodeResources | Updates framework code signature resources after header changes. |
| Editor/IOS/Frameworks/BugSplat.xcframework/Info.plist | Adjusts xcframework slice identifiers/platform variants (tvos device vs simulator entries). |
Comments suppressed due to low confidence (1)
Samples~/my-unity-crasher/Scenes/Sample.unity:1864
- This prefab instance removes component
{fileID: 5305253083977984388}(ForcedCrashEvent) but still contains override modifications targeting it (category,OnForceCrash...). Clean up these stale overrides so the instance no longer references a removed component.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
258
to
264
| m_OnClick: | ||
| m_PersistentCalls: | ||
| m_Calls: | ||
| - m_Target: {fileID: 5305253083977984388} | ||
| - m_Target: {fileID: 0} | ||
| m_TargetAssemblyTypeName: Crasher.ForcedCrashEvent, Assembly-CSharp | ||
| m_MethodName: Event_OnForceCrash | ||
| m_Mode: 1 |
Comment on lines
854
to
+860
| - target: {fileID: 5305253083977984388, guid: de657baed6ab68e4e946d741cdbe94e2, type: 3} | ||
| propertyPath: category | ||
| value: 1 | ||
| objectReference: {fileID: 0} | ||
| - target: {fileID: 5305253083977984388, guid: de657baed6ab68e4e946d741cdbe94e2, type: 3} | ||
| propertyPath: OnForceCrash.m_PersistentCalls.m_Calls.Array.size | ||
| value: 0 |
Unity runs C# on its own player thread, not the Android main/UI thread. BugSplatBridge.hang() blocked the Unity thread, leaving the main thread responsive, so the OS never registered an ANR. Dispatch the hang via Activity.runOnUiThread so the main thread is the one that stalls. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
daveplunkett
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds ANR (Android) and fatal main-thread hang detection (iOS) reporting. Both features already exist in the native libraries — this PR pulls them in and wires them up.
Android — ANR
bugsplat-android-release.aarto v1.3.0 (built from thev1.3.0tag).AnrReporterruns insideBugSplatBridge.initBugSplat(...), no API change. Reports arrive asAndroid.ANR.UseNativeCrashReportingForAndroidis enabled.iOS — fatal hang detection
BugSplat.xcframeworkandBugSplat-macOS.dylibto bugsplat-apple v3.2.0.enableHangDetectionis set in the iOS bridge before[BugSplat start], coupled toUseNativeCrashReportingForIos. Reports arrive asApp Hang (Fatal).Sample
Event_HangNative()._hangNativeIos()shows a confirmation alert (matching the bugsplat-apple example) explaining the force-quit-and-relaunch flow, then blocks the main thread withNSThread sleepUntilDate:— CPU-idle, unlike a spin loop.On Clickwiring and retired the now-unusedForcedCrashEventrelay.Misc
4.1.0.Verification
Android.ANRreport on an API 30+ device via the Hang button.App Hang (Fatal)report — run without the Xcode debugger attached, since hang detection is suppressed under a debugger.Closes #121
🤖 Generated with Claude Code