kiwix/kiwix-android

Move `isFileExist` method to IO thread.

MohitMaliFtechiz opened this issue · 3 comments

See parent issue #4035

Describe the bug
We are using the isFileExist method to check whether the file exists or not, but we are using the runBlocking which uses the mainThred and due to this we are facing an Input dispatching timed out error. The playStore reported this error, and in the last 60 days, there are 2 errors reported by the playStore.

Image

Expected behavior
We should perform this action on the IO thread so that we will not face this type of issue.

Logs

at jdk.internal.misc.Unsafe.park (Native method)
  at java.util.concurrent.locks.LockSupport.parkNanos (LockSupport.java:252)
  at kotlinx.coroutines.BlockingCoroutine.joinBlocking (BlockingCoroutine.java:88)
  at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking (BuildersKt__Builders.kt:59)
  at kotlinx.coroutines.BuildersKt.runBlocking (Builders.kt:1)
  at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default (BuildersKt__Builders.kt:38)
  at kotlinx.coroutines.BuildersKt.runBlocking$default (Builders.kt:1)
  at org.kiwix.kiwixmobile.core.extensions.FileExtensionsKt.isFileExist (FileExtensions.kt:26)
  at org.kiwix.kiwixmobile.core.settings.StorageCalculator.availableBytes (StorageCalculator.java:40)
  at org.kiwix.kiwixmobile.core.settings.StorageCalculator.availableBytes$default (StorageCalculator.java:39)
  at org.kiwix.kiwixmobile.zimManager.libraryView.AvailableSpaceCalculator.hasAvailableSpaceForBook (AvailableSpaceCalculator.java:58)
  at org.kiwix.kiwixmobile.zimManager.libraryView.adapter.LibraryViewHolder$LibraryBookViewHolder.bind (LibraryViewHolder.kt:63)
  at org.kiwix.kiwixmobile.zimManager.libraryView.adapter.LibraryViewHolder$LibraryBookViewHolder.bind (LibraryViewHolder.kt:46)
  at org.kiwix.kiwixmobile.core.base.adapter.AbsDelegateAdapter$DefaultImpls.bind (AbsDelegateAdapter.kt:35)
  at org.kiwix.kiwixmobile.zimManager.libraryView.adapter.LibraryDelegate.bind (LibraryDelegate.kt:35)
  at org.kiwix.kiwixmobile.zimManager.libraryView.adapter.LibraryDelegate.bind (LibraryDelegate.kt:35)
  at org.kiwix.kiwixmobile.core.base.adapter.AdapterDelegateManager.onBindViewHolder (AdapterDelegateManager.java:40)
  at org.kiwix.kiwixmobile.core.base.adapter.BaseDelegateAdapter.onBindViewHolder (BaseDelegateAdapter.kt:57)
  at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder (RecyclerView.java:7065)
  at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder (RecyclerView.java:7107)
  at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline (RecyclerView.java:6012)
  at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline (RecyclerView.java:6279)
  at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:6118)
  at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:6114)
  at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2303)
  at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1627)
  at androidx.recyclerview.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1587)
  at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:665)
  at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2 (RecyclerView.java:4134)
  at androidx.recyclerview.widget.RecyclerView.dispatchLayout (RecyclerView.java:3851)
  at androidx.recyclerview.widget.RecyclerView.onLayout (RecyclerView.java:4404)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at androidx.swiperefreshlayout.widget.SwipeRefreshLayout.onLayout (SwipeRefreshLayout.java:689)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at com.google.android.material.appbar.HeaderScrollingViewBehavior.layoutChild (HeaderScrollingViewBehavior.java:149)
  at com.google.android.material.appbar.ViewOffsetBehavior.onLayoutChild (ViewOffsetBehavior.java:43)
  at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout (CoordinatorLayout.java:918)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at androidx.constraintlayout.widget.ConstraintLayout.onLayout (ConstraintLayout.java:1873)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChild (CoordinatorLayout.java:1213)
  at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild (CoordinatorLayout.java:899)
  at com.google.android.material.appbar.ViewOffsetBehavior.layoutChild (ViewOffsetBehavior.java:66)
  at com.google.android.material.appbar.HeaderScrollingViewBehavior.layoutChild (HeaderScrollingViewBehavior.java:153)
  at com.google.android.material.appbar.ViewOffsetBehavior.onLayoutChild (ViewOffsetBehavior.java:43)
  at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout (CoordinatorLayout.java:918)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at androidx.drawerlayout.widget.DrawerLayout.onLayout (DrawerLayout.java:1263)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at android.widget.LinearLayout.setChildFrame (LinearLayout.java:1829)
  at android.widget.LinearLayout.layoutVertical (LinearLayout.java:1673)
  at android.widget.LinearLayout.onLayout (LinearLayout.java:1582)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at android.widget.FrameLayout.layoutChildren (FrameLayout.java:332)
  at android.widget.FrameLayout.onLayout (FrameLayout.java:270)
  at com.android.internal.policy.DecorView.onLayout (DecorView.java:1442)
  at android.view.View.layout (View.java:25087)
  at android.view.ViewGroup.layout (ViewGroup.java:6835)
  at android.view.ViewRootImpl.performLayout (ViewRootImpl.java:4962)

@MohitMaliFtechiz assign me this

@CalebKL I have assigned you #4037, it is easy to implement. This ticket will create a huge impact on the bookmark, reader, and deleting ZIM files, etc, so let me handle this ticket.

@CalebKL I have assigned you #4037, it is easy to implement. This ticket will create a huge impact on the bookmark, reader, and deleting ZIM files, etc, so let me handle this ticket.

Okay, thats fine.