openHeapGraph: EACCES (Permission denied)
Description
Dump failed and retry every 5s
Steps to Reproduce
Occur in every memory leak
It should dump correctly
Version Information
- LeakCanary version: v2.7
- Android OS version: 11
- Gradle version: 6.5
Additional Information
Could not dump heap
java.lang.RuntimeException: Couldn't dump heap; open("/storage/emulated/0/Download/leakcanary-***/2021-09-23_20-42-21_415.hprof") failed: Operation not permitted
at dalvik.system.VMDebug.dumpHprofData(Native Method)
at dalvik.system.VMDebug.dumpHprofData(VMDebug.java:384)
at dalvik.system.VMDebug.dumpHprofData(VMDebug.java:361)
at android.os.Debug.dumpHprofData(Debug.java:2016)
at leakcanary.internal.AndroidHeapDumper.dumpHeap(AndroidHeapDumper.kt:67)
at leakcanary.internal.HeapDumpTrigger.dumpHeap(HeapDumpTrigger.kt:165)
at leakcanary.internal.HeapDumpTrigger.checkRetainedObjects(HeapDumpTrigger.kt:150)
at leakcanary.internal.HeapDumpTrigger.access$checkRetainedObjects(HeapDumpTrigger.kt:29)
at leakcanary.internal.HeapDumpTrigger$scheduleRetainedObjectCheck$1.run(HeapDumpTrigger.kt:334)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.os.HandlerThread.run(HandlerThread.java:67)
Sounds like this was a known bug on the Android 11 beta (see #1801). Can you reproduce this on the Android 11 release? Emulator or device? Could you provide a repro project and details on the Android env that can repro this?
Duplicated on stock Google Pixel 3a on Android 11, and also on API 30 Emulator.
The steps lead to a reproducible issue, but LeakCanary seems to work if AnkiDroid is in the foreground
https://github.com/ankidroid/Anki-Android/ @ commit 5fe60ed7d2e3baf0699b04dee7b757428bc57d25 on API 30 emulator
- Accept startup messages
- FAB - Add Note
- Enter "Hello" in "Front"
- In the app bar, select "Preview" (not the "Visual Editor" icon)
- Minimise, then Maximise AnkiDroid
- Back, Back + Confirm losing changes (you should be in the deck picker)
- Minimise AnkiDroid
- Click on the LeakCanary notification
Heap analysis failed - dump
java.io.FileNotFoundException: /storage/emulated/0/Download/leakcanary-com.ichi2.anki/2022-01-04_19-21-38_378.hprof: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:492)
at java.io.FileInputStream.<init>(FileInputStream.java:160)
at shark.FileSourceProvider.openStreamingSource(FileSourceProvider.kt:10)
at shark.ConstantMemoryMetricsDualSourceProvider.openStreamingSource(ConstantMemoryMetricsDualSourceProvider.kt:48)
at shark.HprofHeapGraph$Companion.openHeapGraph(HprofHeapGraph.kt:396)
at shark.HprofHeapGraph$Companion.openHeapGraph$default(HprofHeapGraph.kt:394)
at shark.HeapAnalyzer.analyze(HeapAnalyzer.kt:98)
at leakcanary.internal.HeapAnalyzerService.analyzeHeap(HeapAnalyzerService.kt:87)
at leakcanary.internal.HeapAnalyzerService.onHandleIntentInForeground(HeapAnalyzerService.kt:61)
at leakcanary.internal.ForegroundService.onHandleIntent(ForegroundService.kt:55)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:77)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
at libcore.io.Linux.open(Native Method)
at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:254)
at libcore.io.ForwardingOs.open(ForwardingOs.java:166)
at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:7542)
at libcore.io.IoBridge.open(IoBridge.java:478)
... 13 more
Build.VERSION.SDK_INT: 30
Build.MANUFACTURER: Google
LeakCanary version: 2.7
Analysis duration: 20 ms
Heap dump file path: /storage/emulated/0/Download/leakcanary-com.ichi2.anki/2022-01-04_19-21-38_378.hprof
Heap dump timestamp: 1641324101322
Our LeakCanary implementation is new. The commit that introduced it is: https://github.com/ankidroid/Anki-Android/commit/aedf30eb48a9a5578b89c08ea544661f82397bc8
Thanks! Can you give me more details on the specific specs you set up for the API 30 emulator?
AVD Details
Name: Pixel_3a_API_30
CPU/ABI: Google Play Intel Atom (x86)
Path: C:\Users\David\.android\avd\Pixel_3a_API_30.avd
Target: google_apis_playstore [Google Play] (API level 30)
Skin: pixel_3a
SD Card: 512 MB
fastboot.chosenSnapshotFile:
runtime.network.speed: full
hw.accelerometer: yes
hw.device.name: pixel_3a
hw.lcd.width: 1080
hw.initialOrientation: Portrait
image.androidVersion.api: 30
tag.id: google_apis_playstore
hw.mainKeys: no
hw.camera.front: emulated
avd.ini.displayname: Pixel 3a API 30
hw.gpu.mode: auto
hw.ramSize: 1536
PlayStore.enabled: true
fastboot.forceColdBoot: no
hw.cpu.ncore: 2
hw.keyboard: yes
hw.sensors.proximity: yes
hw.dPad: no
hw.lcd.height: 2220
vm.heapSize: 256
skin.dynamic: yes
hw.device.manufacturer: Google
hw.gps: yes
hw.audioInput: yes
image.sysdir.1: system-images\android-30\google_apis_playstore\x86\
showDeviceFrame: yes
hw.camera.back: virtualscene
AvdId: Pixel_3a_API_30
hw.lcd.density: 440
hw.arc: false
hw.device.hash2: MD5:0e6953ebf01bdc6b33a2f54746629c50
fastboot.forceChosenSnapshotBoot: no
fastboot.forceFastBoot: yes
hw.trackBall: no
hw.battery: yes
hw.sdCard: yes
tag.display: Google Play
runtime.network.latency: none
disk.dataPartition.size: 6442450944
hw.sensors.orientation: yes
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes
Thanks! Please let me know if you require more/alternate details
Is this still happening with LeakCanary 2.11 ?
Note: I didn't realize it at the time but the AnkiDroid error is entirely different from the original error in this issue.