-
-
Notifications
You must be signed in to change notification settings - Fork 469
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
Task/anr fix zimfile reader #3937
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CalebKL Thanks for the PR and your hard work. But there are some edge cases and crashes scenarios introduced we should fix them.
There is a crash when I frequently changed the zim files. Also, in UI there is old zim files loading when I am switching to other zim file which is bigger in size. I guess because of this, this crash is happening.
2024-07-16 14:20:19.873 12535-12609 libc org.kiwix.kiwixmobile A Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 12609 (ThreadPoolForeg)
2024-07-16 14:20:19.875 12535-12602 ZimFileReader org.kiwix.kiwixmobile E Could not get Item for url = https://kiwix.app/I/Flag_of_Greece.svg.png.webp
original exception = java.lang.Exception: Cannot find entry
2024-07-16 14:20:19.876 12535-12602 ZimFileReader org.kiwix.kiwixmobile D getting mimetype for https://kiwix.app/I/Flag_of_Greece.svg.png.webp = null
2024-07-16 14:20:19.877 12535-12821 ZimFileReader org.kiwix.kiwixmobile E Could not get Item for url = https://kiwix.app/I/Political_slogan_by_Red_Guards_on_the_campus_of_Fudan_University_1976.jpg.webp
original exception = java.lang.Exception: Cannot find entry
2024-07-16 14:20:19.898 12535-15737 ZimFileReader org.kiwix.kiwixmobile E Could not get Item for url = https://kiwix.app/I/Flag_of_Greece.svg.png.webp
original exception = java.lang.Exception: Cannot find entry
2024-07-16 14:20:19.904 12535-12535 AppCompatViewInflater org.kiwix.kiwixmobile I app:theme is now deprecated. Please move to using android:theme instead.
2024-07-16 14:20:19.911 12535-12535 CubicBezierInterpolator org.kiwix.kiwixmobile D CubicBezierInterpolator mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
2024-07-16 14:20:19.912 12535-12535 CubicBezierInterpolator org.kiwix.kiwixmobile D CubicBezierInterpolator mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
2024-07-16 14:20:19.913 12535-12535 CubicBezierInterpolator org.kiwix.kiwixmobile D CubicBezierInterpolator mControlPoint1x = 0.23, mControlPoint1y = 0.06, mControlPoint2x = 0.09, mControlPoint2y = 0.97
2024-07-16 14:20:19.913 12535-12535 CubicBezierInterpolator org.kiwix.kiwixmobile D CubicBezierInterpolator mControlPoint1x = 0.6, mControlPoint1y = 0.9, mControlPoint2x = 0.8, mControlPoint2y = 1.0
2024-07-16 14:20:20.129 17250-17250 DEBUG pid-17250 A pid: 12535, tid: 12609, name: ThreadPoolForeg >>> org.kiwix.kiwixmobile <<<
2024-07-16 14:20:20.132 17250-17250 DEBUG pid-17250 A #00 pc 0000000000010630 /data/app/org.kiwix.kiwixmobile-G5GGa4VbPmK5Z5zSGKhzQw==/base.apk (offset 0x71f000)
2024-07-16 14:20:20.132 17250-17250 DEBUG pid-17250 A #01 pc 000000000005be38 /data/app/org.kiwix.kiwixmobile-G5GGa4VbPmK5Z5zSGKhzQw==/oat/arm64/base.odex (offset 0x46000)
core/src/main/java/org/kiwix/kiwixmobile/core/reader/ZimReaderContainer.kt
Outdated
Show resolved
Hide resolved
app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt
Outdated
Show resolved
Hide resolved
core/src/main/java/org/kiwix/kiwixmobile/core/main/CoreReaderFragment.kt
Outdated
Show resolved
Hide resolved
.../src/main/java/org/kiwix/kiwixmobile/core/page/notes/viewmodel/effects/ShowOpenNoteDialog.kt
Outdated
Show resolved
Hide resolved
@MohitMaliFtechiz When I switch to different zimFiles, I get this crash after numerous attempts. Cmdline: org.kiwix.kiwixmobile
2024-07-18 12:44:02.286 5611-5611 DEBUG pid-5611 A pid: 5387, tid: 5606, name: DefaultDispatch >>> org.kiwix.kiwixmobile <<<
2024-07-18 12:44:02.286 5611-5611 DEBUG pid-5611 A #00 pc 0000000000010630 /data/app/~~2cz1tgEo0aQgZshuQoQHsg==/org.kiwix.kiwixmobile-ZpQbVVYb8qkV5KrowJ_Pfg==/base.apk!libzim_wrapper.so (offset 0x1b2a000) (Java_org_kiwix_libzim_Archive_getEntryByPath__Ljava_lang_String_2+120) (BuildId: bb96395f5068f1755a93f5daa08b7a934333f07e)
2024-07-18 12:44:02.286 5611-5611 DEBUG pid-5611 A #02 pc 00000000020ad728 /memfd:jit-cache (deleted) (offset 0x2000000) (org.kiwix.kiwixmobile.core.reader.ZimFileReader.getItem+376)
2024-07-18 12:44:02.286 5611-5611 DEBUG pid-5611 A #03 pc 000000000214569c /memfd:jit-cache (deleted) (offset 0x2000000) (org.kiwix.kiwixmobile.core.reader.ZimFileReader.loadContent+204)
2024-07-18 12:44:02.286 5611-5611 DEBUG pid-5611 A #08 pc 0000000000008cd0 /data/data/org.kiwix.kiwixmobile/code_cache/.overlay/base.apk/classes13.dex (org.kiwix.kiwixmobile.core.reader.ZimFileReader.access$loadContent+0) |
@CalebKL No it is not that crash i have uploaded the crash logs in the review comment. Also, now on my device, it is crashing immediately when I switch to other zim files(I am using the old version of Android for testing Android 8). Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 11992 (DefaultDispatch)
2024-07-18 16:33:50.291 12077-12077 DEBUG pid-12077 A pid: 11734, tid: 11992, name: DefaultDispatch >>> org.kiwix.kiwixmobile <<<
2024-07-18 16:33:50.294 12077-12077 DEBUG pid-12077 A #00 pc 0000000000010630 /data/app/org.kiwix.kiwixmobile-YaobaHgoDzW2aibsfWri3g==/base.apk (offset 0x71f000)
2024-07-18 16:33:50.294 12077-12077 DEBUG pid-12077 A #01 pc 000000000005be38 /data/app/org.kiwix.kiwixmobile-YaobaHgoDzW2aibsfWri3g==/oat/arm64/base.odex (offset 0x46000) In the CoreReaderFragment there is a Currently, it is somehow restoring the previous zim file and tabs when we open the new file. However, it should not do it according to our |
This crash is newer, on which device you are testing. |
let me look into this as well |
I got this crash while testing on my emulator, Pixel 7 pro API34 and also on Samsung S22+ |
@CalebKL Thanks, it is a native crash in libzim, but currently, our PR has many bugs and workarounds that can lead to this issue, so probably first we have to fix these things. @mgautierfr can have a better idea about this error when it occurs. Might be the data is corrupted at some point due to these scenarios. |
Any news here? |
There are some fixes that I am working on from @MohitMaliFtechiz reviews. I will complete it ASAP, although this PR will need to wait until the native error(3956) causing the crash is fixed. |
@CalebKL I have found some serious issues in our implementation, especially when working with In the meantime, we have also improved our code. So now, we have a better coroutine implementation to create an archive object on the IO thread. Also, we have improved the UI side to properly show users the progress when the archive object is in the creation process: #4074. So now, you can start working on my review comments. |
@MohitMaliFtechiz Can you please complete PR |
5 months without activity, this is too long by far, it should be completed. |
Completing this ASAP |
@MohitMaliFtechiz Please complete PR |
e7933dd
to
be27f71
Compare
@CalebKL I have made the necessary changes, you can test and give your feedback. |
@MohitMaliFtechiz Please rebase |
…ince the ZIM file is already set in the reader
…restoring them. * Improved the tab closing and restoring process. Previously, when the user closed all tabs, the `ZimFileReader` was set to null. If the user restored the tabs, a new `ZimFileReader` was created, which was a resource-intensive operation, especially for large ZIM files. * Now, the `ZimFileReader` is not set to null while the "restore tab" snackbar is visible, allowing users to restore tabs without recreating the ZimFileReader. * Once the snackbar is dismissed, the `ZimFileReader` is set to null to free up resources since it is no longer required.
…in note screen since now we are not creating the ZimFileReader on note screen.
…eReader object to convert the files into Books. * Refactored the `StorageObserverTest` to align with this new change.
d3c7656
to
053b6e0
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3937 +/- ##
============================================
+ Coverage 56.68% 56.73% +0.04%
- Complexity 1527 1532 +5
============================================
Files 313 313
Lines 13490 13510 +20
Branches 1693 1695 +2
============================================
+ Hits 7647 7665 +18
- Misses 4678 4681 +3
+ Partials 1165 1164 -1 ☔ View full report in Codecov by Sentry. |
@kelson42 Done. |
Fixes #3929
zimFileReader
object. The UI was being blocked since we were creating the object onIO
Thread but we are usingrunblocking
which blocks the main thread. The solution to the problem was tosuspend
setZimFile
andsetZimFileDescriptor
. Then tie the scope onlifecycleScope
on the Fragments. When thezimFileReader
is being created and it takes time for the initial load, theprogressBar
will be visible to the users and when Loading is complete, theprogressBar
will be Gone.The solution doesn't block the
Main
Thread and instead switches the background work to a different thread(IO
)AddNoteDialog
to use database values for performing note-related operations (e.g., view, edit, delete notes) instead of setting and usingZimFileReader
.ZimFileReader
was set to null. If the user restored the tabs, a newZimFileReader
was created, which was a resource-intensive operation, especially for large ZIM files.ZimFileReader
is not set to null while the "restore tab" snackbar is visible, allowing users to restore tabs without recreating the ZimFileReader.ZimFileReader
is set to null to free up resources since it is no longer required.By doing the above changes now our UI is working flawlessly as there is no extra ZilFileReader creation happens. See the below video.
screen-20250121-171439.mp4