Fixed: Sometimes application crashes due to a native crash when we frequently load the ZIM files in the reader. #4105
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4104
There were 2 issues that caused this error.
lifecycleScope
, but we encountered an issue where thelifecycleScope
remained active when navigating away from the reader fragment. Since the fragment was still in thebackStack
, 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 previousarchive
object was disposed of when the new ZIM file was added, and WebView tried to load content from the disposedarchive
object. To address this, we switched to usingcoreReaderLifeCycleScope
and ensured that any ongoing operations related to setting the new ZIM file are canceled if the reader screen is destroyed.onDestroyView
method but not stopping WebView's internal processes. As a result, the WebViews continued calling theshouldInterceptRequest
method, which loaded internal links on the page. When a new archive object was assigned to theZimFileReader
, the previous archive was disposed of, but the WebView continued trying to load content from the disposedarchive
, causing an error. To fix this, we now properly stop all WebView loading before setting the new ZIM file in thearchive
. Additionally, we ensure that when switching to other screens, unnecessary resources are not loaded when they are no longer needed.screen-20241122-162059.mp4