Skip to content

[BUG] OOM in ANRTracker #174

@mpurbo

Description

@mpurbo

Bug Description

OOM when ANRTracker is trying to collect stack trace.

Exception java.lang.OutOfMemoryError:
at java.util.Arrays.copyOf (Arrays.java:3257)
at java.lang.AbstractStringBuilder.ensureCapacityInternal (AbstractStringBuilder.java:124)
at java.lang.AbstractStringBuilder.append (AbstractStringBuilder.java:448)
at java.lang.StringBuilder.append (StringBuilder.java:137)
at com.grafana.faro.ANRTracker.handleAnrDetected (ANRTracker.java:178)
at com.grafana.faro.ANRTracker.run (ANRTracker.java:113)

Reference: https://github.com/grafana/faro-flutter-sdk/blob/main/android/src/main/java/com/grafana/faro/ANRTracker.java#L178

Steps to Reproduce

Hard to reproduce. This problem is crashing our app (infrequently). I assume because on some low-end devices, the ANR happens, the memory is low, and the stack trace is too big (Reference: https://github.com/grafana/faro-flutter-sdk/blob/main/android/src/main/java/com/grafana/faro/ANRTracker.java#L173)

Expected Behavior

The number of stack traces sent (built into the String) is limited (or configurable).

Actual Behavior

All stack traces in the main thread are dumped.

Environment

  • Flutter version: 3.16.0
  • Dart version: 3.2.0
  • Faro Flutter SDK version: 0.3.4
  • Platform: Android
  • Device: Infinix Infinix-X657B, Redmi dandelion
  • OS Version: Android 10, Android 11

Code Sample

No special code.

Additional Context

Checklist

  • I have searched existing issues to ensure this is not a duplicate
  • I have provided all the requested information above
  • I have tested with the latest version of the SDK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions