Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Externally removed resources cause crash #76

Closed
kirillt opened this issue Sep 21, 2021 · 4 comments
Closed

Externally removed resources cause crash #76

kirillt opened this issue Sep 21, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@kirillt
Copy link
Member

kirillt commented Sep 21, 2021

These two logs are caused by "disappeared" resources, i.e. resources which are removed externally from currently presented folder. We need to check out resource list every time before sorting or other adapter updates.

1:

            E/AndroidRuntime: FATAL EXCEPTION: main
    Process: space.taran.arknavigator, PID: 15554
    java.lang.RuntimeException: Unable to resume activity {space.taran.arknavigator/space.taran.arknavigator.ui.activity.MainActivity}: java.nio.file.NoSuchFileException: /storage/9C33-6BBD/Pictures/Screenshots/Screenshot_20210921_215909_saschpe.alphaplus.jpg
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4430)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4470)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2199)
        at android.os.Handler.dispatchMessage(Handler.java:112)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7625)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
     Caused by: java.nio.file.NoSuchFileException: /storage/9C33-6BBD/Pictures/Screenshots/Screenshot_20210921_215909_saschpe.alphaplus.jpg
        at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
        at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
        at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:115)
        at java.nio.file.Files.readAttributes(Files.java:1737)
        at java.nio.file.Files.getLastModifiedTime(Files.java:2266)
        at space.taran.arknavigator.mvp.presenter.adapter.ResourcesGridPresenter$sortAndUpdateAdapter$$inlined$sortBy$4.compare(Comparisons.kt:321)
        at java.util.TimSort.binarySort(TimSort.java:296)
        at java.util.TimSort.sort(TimSort.java:239)
        at java.util.Arrays.sort(Arrays.java:1498)
        at java.util.ArrayList.sort(ArrayList.java:1470)
        at java.util.Collections.sort(Collections.java:201)
        at kotlin.collections.CollectionsKt__MutableCollectionsJVMKt.sortWith(MutableCollectionsJVM.kt:42)
        at space.taran.arknavigator.mvp.presenter.adapter.ResourcesGridPresenter.sortAndUpdateAdapter(ResourcesGridPresenter.kt:105)
        at space.taran.arknavigator.mvp.presenter.adapter.ResourcesGridPresenter.updateResources(ResourcesGridPresenter.kt:73)
        at space.taran.arknavigator.mvp.presenter.ResourcesPresenter.onSelectionChange(ResourcesPresenter.kt:138)
        at space.taran.arknavigator.mvp.presenter.ResourcesPresenter.access$onSelectionChange(ResourcesPresenter.kt:21)
        at space.taran.arknavigator.mvp.presenter.ResourcesPresenter$tagsSelectorPresenter$1.invoke(ResourcesPresenter.kt:45)
        at space.taran.arknavigator.mvp.presenter.ResourcesPresenter$tagsSelectorPresenter$1.invoke(ResourcesPresenter.kt:45)
        at space.taran.arknavigator.mvp.presenter.adapter.TagsSelectorPresenter.calculateTagsAndSelection(TagsSelectorPresenter.kt:109)
        at space.taran.arknavigator.mvp.presenter.ResourcesPresenter.onViewResume(ResourcesPresenter.kt:111)
        at space.taran.arknavigator.ui.fragments.ResourcesFragment.onResume(ResourcesFragment.kt:121)
        at androidx.fragment.app.Fragment.performResume(Fragment.java:3039)
        at androidx.fragment.app.FragmentStateManager.resume(FragmentStateManager.java:607)
        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:306)
        at androidx.fragment.app.FragmentStore.moveToExpectedState(FragmentStore.java:112)
        at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1647)
        at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3128)
        at androidx.fragment.app.FragmentManager.dispatchResume(FragmentManager.java:3086)
        at androidx.fragment.app.FragmentController.dispatchResume(FragmentController.java:273)
        at androidx.fragment.app.FragmentActivity.onResumeFragments(FragmentActivity.java:458)
        at space.taran.arknavigator.ui.activity.MainActivity.onResumeFragments(MainActivity.kt:181)
        at androidx.fragment.app.FragmentActivity.onPostResume(FragmentActivity.java:447)
        at androidx.appcompat.app.AppCompatActivity.onPostResume(AppCompatActivity.java:240)
        at android.app.Activity.performResume(Activity.java:7641)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4412)
            ... 11 more

2:

E/an.arknavigato: [qarth_debug:]  get PatchStore::createDisableExceptionQarthFile method fail.
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: space.taran.arknavigator, PID: 13985
    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:534)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987) 
     Caused by: java.nio.file.NoSuchFileException: /storage/9C33-6BBD/Pictures/Screenshots/Screenshot_20210921_231658_saschpe.alphaplus.jpg
        at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
        at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
        at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:115)
        at java.nio.file.Files.readAttributes(Files.java:1737)
        at java.nio.file.Files.getLastModifiedTime(Files.java:2266)
        at space.taran.arknavigator.mvp.presenter.adapter.ResourcesGridPresenter$sortAndUpdateAdapter$$inlined$sortBy$4.compare(Comparisons.kt:321)
        at java.util.TimSort.binarySort(TimSort.java:296)
        at java.util.TimSort.sort(TimSort.java:239)
        at java.util.Arrays.sort(Arrays.java:1498)
        at java.util.ArrayList.sort(ArrayList.java:1470)
        at java.util.Collections.sort(Collections.java:201)
        at kotlin.collections.CollectionsKt__MutableCollectionsJVMKt.sortWith(MutableCollectionsJVM.kt:42)
        at space.taran.arknavigator.mvp.presenter.adapter.ResourcesGridPresenter.sortAndUpdateAdapter(ResourcesGridPresenter.kt:105)
        at space.taran.arknavigator.mvp.presenter.adapter.ResourcesGridPresenter.updateResources(ResourcesGridPresenter.kt:73)
        at space.taran.arknavigator.mvp.presenter.ResourcesPresenter.onSelectionChange(ResourcesPresenter.kt:138)
        at space.taran.arknavigator.mvp.presenter.ResourcesPresenter.access$onSelectionChange(ResourcesPresenter.kt:21)
        at space.taran.arknavigator.mvp.presenter.ResourcesPresenter$tagsSelectorPresenter$1.invoke(ResourcesPresenter.kt:45)
        at space.taran.arknavigator.mvp.presenter.ResourcesPresenter$tagsSelectorPresenter$1.invoke(ResourcesPresenter.kt:45)
        at space.taran.arknavigator.mvp.presenter.adapter.TagsSelectorPresenter.calculateTagsAndSelection(TagsSelectorPresenter.kt:109)
        at space.taran.arknavigator.mvp.presenter.ResourcesPresenter.onViewResume(ResourcesPresenter.kt:111)
        at space.taran.arknavigator.ui.fragments.ResourcesFragment.onResume(ResourcesFragment.kt:121)
        at androidx.fragment.app.Fragment.performResume(Fragment.java:3039)
        at androidx.fragment.app.FragmentStateManager.resume(FragmentStateManager.java:607)
        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:306)
        at androidx.fragment.app.SpecialEffectsController$FragmentStateManagerOperation.complete(SpecialEffectsController.java:742)
        at androidx.fragment.app.SpecialEffectsController$Operation.completeSpecialEffect(SpecialEffectsController.java:669)
        at androidx.fragment.app.DefaultSpecialEffectsController$SpecialEffectsInfo.completeSpecialEffect(DefaultSpecialEffectsController.java:779)
        at androidx.fragment.app.DefaultSpecialEffectsController.startAnimations(DefaultSpecialEffectsController.java:146)
        at androidx.fragment.app.DefaultSpecialEffectsController.executeOperations(DefaultSpecialEffectsController.java:119)
        at androidx.fragment.app.SpecialEffectsController.executePendingOperations(SpecialEffectsController.java:294)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2202)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2100)
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2002)
        at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
        at android.os.Handler.handleCallback(Handler.java:907)
        at android.os.Handler.dispatchMessage(Handler.java:105)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7625)
        	... 3 more
@kirillt kirillt added the bug Something isn't working label Sep 21, 2021
@kirillt
Copy link
Member Author

kirillt commented Sep 21, 2021

Or more performant way would be to listen for filesystem events on folders presented in resources grid and update internal collection only when something happens (don't confuse with #27).

@kirillt
Copy link
Member Author

kirillt commented Sep 22, 2021

Should be enough to use FileObserver: https://developer.android.com/reference/android/os/FileObserver
Note that, if we have prefix selected (favorite), then we need subscribe not to root, but to the prefix

@kirillt
Copy link
Member Author

kirillt commented Feb 2, 2022

We should measure power consumption of file system monitoring. If it's high enough, just refreshing in necessary moments should be used instead of file system monitoring.

@kirillt
Copy link
Member Author

kirillt commented Feb 24, 2022

Fixed in #214

@kirillt kirillt closed this as completed Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants