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

Fixed: Sometimes application crashes due to a native crash when we frequently load the ZIM files in the reader. #4105

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

MohitMaliFtechiz
Copy link
Collaborator

@MohitMaliFtechiz MohitMaliFtechiz commented Nov 22, 2024

Fixes #4104

There were 2 issues that caused this error.

  • We were previously using lifecycleScope, but we encountered an issue where the lifecycleScope remained active when navigating away from the reader fragment. Since the fragment was still in the backStack, the scope continued running and attempted to set the new ZIM file, even though the reader screen was no longer visible. When we tried to open a new ZIM file, both files were attempting to load in the reader, causing the main page to load content from both files. This happened because the previous archive object was disposed of when the new ZIM file was added, and WebView tried to load content from the disposed archive object. To address this, we switched to using coreReaderLifeCycleScope and ensured that any ongoing operations related to setting the new ZIM file are canceled if the reader screen is destroyed.
  • The second issue was that we were clearing the WebView list in our onDestroyView method but not stopping WebView's internal processes. As a result, the WebViews continued calling the shouldInterceptRequest method, which loaded internal links on the page. When a new archive object was assigned to the ZimFileReader, the previous archive was disposed of, but the WebView continued trying to load content from the disposed archive, causing an error. To fix this, we now properly stop all WebView loading before setting the new ZIM file in the archive. Additionally, we ensure that when switching to other screens, unnecessary resources are not loaded when they are no longer needed.
  • Added the necessary comments in code for future reference.
screen-20241122-162059.mp4

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as draft November 22, 2024 10:14
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 64.28571% with 10 lines in your changes missing coverage. Please review.

Project coverage is 58.46%. Comparing base (3305a26) to head (c86c156).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
.../kiwix/kiwixmobile/core/main/CoreReaderFragment.kt 77.27% 3 Missing and 2 partials ⚠️
...ile/nav/destination/library/CopyMoveFileHandler.kt 0.00% 3 Missing ⚠️
...bile/nav/destination/reader/KiwixReaderFragment.kt 33.33% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4105      +/-   ##
============================================
- Coverage     58.66%   58.46%   -0.21%     
+ Complexity     1549     1534      -15     
============================================
  Files           316      316              
  Lines         13330    13351      +21     
  Branches       1698     1700       +2     
============================================
- Hits           7820     7805      -15     
- Misses         4390     4413      +23     
- Partials       1120     1133      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@kelson42
Copy link
Collaborator

@MohitMaliFtechiz What is the status here? Could we merge and move forward with release?

@MohitMaliFtechiz MohitMaliFtechiz marked this pull request as ready for review November 22, 2024 15:40
@MohitMaliFtechiz
Copy link
Collaborator Author

@kelson42 The PR is ready for review and merge now.

@kelson42 kelson42 merged commit fff3c3e into main Nov 22, 2024
21 of 22 checks passed
@kelson42 kelson42 deleted the Fixes#4104 branch November 22, 2024 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sometimes application crashes due to a native crash when we frequently load the ZIM files in the reader.
3 participants