fix(android): cap ANR stack traces to reduce OOM risk#207
Draft
robert-northmind wants to merge 2 commits intomainfrom
Draft
fix(android): cap ANR stack traces to reduce OOM risk#207robert-northmind wants to merge 2 commits intomainfrom
robert-northmind wants to merge 2 commits intomainfrom
Conversation
Limit main-thread stack string to 128 frames and 64 KiB, add JSON metadata for truncation, and log a short summary instead of the full trace. Addresses #174. Co-authored-by: Robert Magnusson <robert-northmind@users.noreply.github.com>
|
|
Extract AnrStackTraceFormatter for pure-Java unit tests and a Gradle subproject that compiles only that file. CI runs :anr-stack-formatter-tests:test. Enforce final string length <= maxChars so tiny limits cannot exceed the cap. Co-authored-by: Robert Magnusson <robert-northmind@users.noreply.github.com>
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.
Description
This change bounds how much of the main thread stack we stringify when the in-app ANR watchdog fires. Deep Flutter stacks can be very large; building and logging unbounded strings on low-memory devices contributed to
OutOfMemoryErrorduring ANR capture (see #174).stacktrace_truncated,stacktrace_total_frames,stacktrace_included_frames.Log.wwith a short summary (included/total frames, truncated flag).AnrStackTraceFormatter(pure Java) with JUnit tests inandroid/anr-stack-formatter-tests; CI runs./gradlew :anr-stack-formatter-tests:test. The formatter guarantees the returned string length never exceedsmaxChars(including truncation suffix).Related Issue(s)
Fixes #174
Type of Change
Checklist
Additional Notes
TDD-style: tests were added for max frame count, max character budget, and global length bound; a follow-up fix ensures the formatted string is hard-capped at
maxCharswhen the truncation note would otherwise exceed the limit.dart tool/pre_release_check.dartpasses locally.