CrashHandler: install once and dispatch each crash once

Merged
UT
5d ago
+67-4

Description

Split out of #1570 so the HTML5 runtime PR stays about HTML5. The three commits are by @jeremybernstein, unchanged:

  • CrashHandler.initialize no longer wraps a previous CrashHandler, so repeated app boots (Robolectric runs one per test class) do not grow the handler chain.
  • A failed crash-file save is logged instead of handing the crash to the default handler a second time.
  • CrashFingerprint.extract caps each line at the same 4096 chars GuestOutputTail uses; one very long line made some patterns backtrack for minutes.

Adds CrashHandlerTest covering repeated init and a failed save.

Recording

None; no UI change.

Type of Change

  • Bug fix
  • Performance / stability improvement
  • Compatibility improvements
  • Other (requires prior approval)

Checklist

  • If I have access to #code-changes, I have discussed this change there and it has been green-lighted. If I do not have access, I have still provided clear context in this PR. If I skip both, I accept that this change may face delays in review, may not be reviewed at all, or may be closed.
  • This change aligns with the current project scope (core functionality, stability, or performance). If not, it has been explicitly approved beforehand.
  • I have attached a recording of the change.
  • I have read and agree to the contribution guidelines in CONTRIBUTING.md.

Summary by cubic

Fixes CrashHandler so repeated app boots no longer grow the handler chain and each crash reaches the default handler exactly once.

  • CrashHandler.initialize unwraps an already-installed CrashHandler instead of wrapping it again per boot.
  • Failed crash-file saves are logged rather than dispatched to the default handler a second time.
  • CrashFingerprint.extract caps each line at 4096 chars, matching GuestOutputTail, to prevent quadratic backtracking on very long lines.
  • Adds CrashHandlerTest covering repeated init and a failed save.

Summary by CodeRabbit

  • Bug Fixes
    • Improved crash handling so repeated initialization does not cause an exception to be passed to the original handler multiple times.
    • Improved handling when saving a crash report fails, while preserving the normal exception handoff.
    • Applied a consistent 4,096-character limit to lines used in crash fingerprinting and retained guest output.