Fenix: FNX-14389 โƒ [Bug] java.io.IOException: not a readable directory: /data/user/0/org.mozilla.fenix/cache/mozac_browser_thumbnails/thumbnails

Created on 2 Aug 2020  ยท  8Comments  ยท  Source: mozilla-mobile/fenix

Steps to reproduce

  1. Delete all browsing data using _Settings_, _Delete browsing data_
  2. Open a website, e.g. https://www.mozilla.org/en-GB/
  3. Close the tab
  4. Open up the phone's _Settings_ and clear the cached data for all apps (can vary by Android version and manufacturer)
  5. _Quickly_ switch to the browser and repeat step 1

Expected behavior

The browser deletes the browsing data or displays an error if it fails to do this.

Actual behavior

The browser crashes with the following stacktrace:

84fa9603-a48c-4cdd-8b15-04a9d1b68084
java.io.IOException: not a readable directory: /data/user/0/org.mozilla.fenix/cache/mozac_browser_thumbnails/thumbnails

* Sentry: https://sentry.prod.mozaws.net/operations/firefox-nightly/?query=b3b6fefc3e114ee99b20b1e650375902

java.io.IOException: not a readable directory: /data/user/0/org.mozilla.fenix/cache/mozac_browser_thumbnails/thumbnails
    at com.jakewharton.disklrucache.Util.deleteContents(Util.java:7)
    at com.jakewharton.disklrucache.DiskLruCache.delete(DiskLruCache.java:2)
    at mozilla.components.browser.thumbnails.utils.ThumbnailDiskCache.clear$browser_thumbnails_release(ThumbnailDiskCache.kt:2)
    at mozilla.components.browser.thumbnails.storage.ThumbnailStorage$clearThumbnails$1.invokeSuspend(ThumbnailStorage.kt:4)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:3)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:21)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)

Device information

  • Android device: Sony Xperia Z2, Android 6.0.1
  • Fenix version: Nightly 200802 06:16 (Build #22150626)
    AC: 53.0.20200801130512, c6137485e
    GV: 81.0a1-20200730093956
    AS: 61.0.10
crash ac ๐Ÿž bug

All 8 comments

I'm not sure what we could do about this besides catch the exception if we have to race the user to delete the thumbnail cache before they delete all the app caches right after.

I walked through the code and we're locking our mutex when we call the LRU cache.

The issue only occurs when first clearing the cached data via the OS and then quickly using Fenix to delete the thumbnail cache. I guess the OS still has a lock on the data. If I wait long enough after starting the OS cached data clearing procedure, I do not get a crash by Fenix. I only included the first STR step to demonstrate that this does not need to be a large number of files/thumbnails, at least on my device.

That makes sense. It sounds like deleting the thumbnails where each one is multiple MB large can take a while and we're trying to then delete a directory that has already been deleted.

Catching this exception is probably the safest way forward since there isn't anything else we need to do to ensure a clean state.

Thanks for filling the issue and the context, much appreciated!

I don't see this exception any more in nightly. Closing for now as it rides the trains.

@jonalmeida I can still reproduce on Nightly 201216 17:01 (Build #2015781769) on the same device and using the same STR as the original report, see the following crash report:

java.io.IOException: not a readable directory: /data/user/0/org.mozilla.fenix/cache/mozac_browser_icons/resources
 * Sentry: https://sentry.prod.mozaws.net/operations/fenix/?query=c95e01518d404b1ca38f2636d654e8f2
 * Socorro: https://crash-stats.mozilla.org/report/index/bp-cf7ad22a-4053-4add-a84e-8ba720201217
----
java.io.IOException: not a readable directory: /data/user/0/org.mozilla.fenix/cache/mozac_browser_icons/resources
    at com.jakewharton.disklrucache.Util.deleteContents(Util.java:7)
    at com.jakewharton.disklrucache.DiskLruCache.delete(DiskLruCache.java:2)
    at mozilla.components.browser.icons.utils.IconDiskCache.clear$browser_icons_release(IconDiskCache.kt:1)
    at mozilla.components.browser.icons.BrowserIcons.clear(BrowserIcons.kt:1)
    at org.mozilla.fenix.settings.deletebrowsingdata.DefaultDeleteBrowsingDataController$deleteBrowsingData$2.invokeSuspend(DeleteBrowsingDataController.kt:10)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:3)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:15)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:234)
    at android.app.ActivityThread.main(ActivityThread.java:5526)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

This looks like a similar crash but for a browser-icons.

My patch was only for the thumbnails storage. I think we can easily copy it over there though. If you could file a new ticket for that, it would be helpful, otherwise I'll get to it soon.

Thanks for reporting back! ๐Ÿ™‚

This looks like a similar crash but for a browser-icons.

You are totally right, that is a different stacktrace message.

My patch was only for the thumbnails storage. I think we can easily copy it over there though. If you could file a new ticket for that, it would be helpful, otherwise I'll get to it soon.

I have opened #17103 (now https://github.com/mozilla-mobile/android-components/issues/9269) to track this in the Fenix repository. I hope that is what you meant, I could also have opened an AC issue for this ๐Ÿ˜„

No worries, this works. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

csadilek picture csadilek  ยท  3Comments

vesta0 picture vesta0  ยท  3Comments

lindongbin picture lindongbin  ยท  3Comments

abodea picture abodea  ยท  3Comments

phileastv picture phileastv  ยท  3Comments