Open Bug 1641119 Opened 4 years ago Updated 4 years ago

Handle OutOfMemoryError exceptions when allocating Java samples buffer

Categories

(Core :: Gecko Profiler, defect, P2)

ARM
Android
defect

Tracking

()

People

(Reporter: mstange, Unassigned)

References

(Blocks 1 open bug)

Details

With my current startup profiling settings, Fenix Nightly crashes on startup. adb logcat contains the following:

05-26 21:39:21.393 13101 13136 W zygote  : Throwing OutOfMemoryError "Failed to allocate a 268435472 byte allocation with 718464 free bytes and 189MB until OOM, max allowed footprint 2873856, growth limit 201326592"
05-26 21:39:21.394 13101 13136 W System.err: java.lang.OutOfMemoryError: Failed to allocate a 268435472 byte allocation with 718464 free bytes and 189MB until OOM, max allowed footprint 2873856, growth limit 201326592
05-26 21:39:21.394 13101 13136 W System.err: 	at org.mozilla.gecko.GeckoJavaSampler$SamplingRunnable.<init>(GeckoJavaSampler.java:5)
05-26 21:39:21.394 13101 13136 W System.err: 	at org.mozilla.gecko.GeckoJavaSampler.start(GeckoJavaSampler.java:6)
05-26 21:39:21.394 13101 13136 W System.err: 	at org.mozilla.gecko.mozglue.GeckoLoader.nativeRun(Native Method)
05-26 21:39:21.394 13101 13136 W System.err: 	at org.mozilla.gecko.GeckoThread.run(GeckoThread.java:91)

Can we handle this more gracefully? Here's my current org.mozilla.fenix.nightly-geckoview-config.yaml:

env:
  MOZ_PROFILER_STARTUP: 1
  MOZ_PROFILER_STARTUP_INTERVAL: 5
  MOZ_PROFILER_STARTUP_FEATURES: threads,js,stackwalk,leaf,java,screenshots,ipcmessages
  MOZ_PROFILER_STARTUP_FILTERS: GeckoMain,Compositor,Renderer,SaveScripts,Parser

(Push to the device using adb push org.mozilla.fenix.nightly-geckoview-config.yaml /data/local/tmp/ and also run adb shell am set-debug-app --persistent org.mozilla.fenix.nightly so that the yaml file is respected by Fenix Nightly.)

So I seem to be using the default value for the entries count.

This is on a Moto G5.

I filed bug 1641122 on the fact that the default value is too high for the device. Let's use this bug just to avoid crashing when the value is too high.

Thanks for the report! You are right about gracefully handling the OutOfMemoryError exceptions. We should fix that but as I said on the other bug, this is most likely happening because of Bug 1639630. We were trying to allocate the same amount of memory with the C++ side because of a typo. Now it should be capped to ~900kb max which is enough for at least 2mins of sampling. So I think this OutOfMemoryError is going to happen a lot less frequently in the future.

Indeed, after updating today, the crash no longer happens. The most recent Fenix build yesterday was still on a Gecko build from May 22nd.

S1 or S2 bugs need an assignee - could you find someone for this bug?

Flags: needinfo?(gsquelart)

Now less severe thanks to bug 1641122 (defaults were too high on 32-bit Android, making this bug here more likely to happen).

Severity: S2 → S3
Flags: needinfo?(gsquelart)

Seeing this on a Moto G XT1031. Let me know what information might be helpful here.

https://github.com/mozilla-mobile/fenix/issues/10870

Asif, it would be useful to know what settings you used to start the profiler. Thanks!

Settings are:

Interval: 1 ms
Threads: GeckoMain, Compositor, Renderer
Java
JavaScript
Native Leaf Stack
Native Stacks

What's the buffer size?

Last time I tested, 128 MiB.

You need to log in before you can comment on or make changes to this bug.