Run Cleanup delete and Browse-All index rebuild off the UI thread#18
Merged
Conversation
Both did bulk file IO on the click handler: Cleanup deletes every file of a mirror and rebuilds the top index, and Browse-All regenerates the aggregate index across all projects. On a large mirror this blows past the ANR budget and freezes the app. The legacy-import path was already moved off-thread for the same reason; these two follow the same pattern — snapshot on the UI thread, do the work on a named worker, post the result back through a main-looper Handler guarded by isFinishing()/isDestroyed(). Cleanup's row-disable also gains a null guard on getChildAt (a scrolled-off row returns null), a latent NPE independent of the threading move. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Xavier Roche <roche@httrack.com>
Signed-off-by: Xavier Roche <roche@httrack.com> # Conflicts: # app/src/main/java/com/httrack/android/HTTrackActivity.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Cleanup delete and Browse-All both did bulk file IO on the click handler. Cleanup deletes every file of a mirror and rebuilds the top index; Browse-All regenerates the aggregate index across all projects. On a large mirror either one blows past the ANR budget and freezes the app. The legacy-import path was already moved off-thread for the same reason, so these follow that pattern: snapshot on the UI thread, do the work on a named worker, and post the result back through a main-looper Handler guarded by
isFinishing()/isDestroyed().Cleanup's row-disable also gains a null guard on
getChildAt, since a scrolled-off row returns null. That is a latent NPE independent of the threading move.From the pre-KVM audit (finding #3 high, #6 medium). The ANR actually being gone on a tens-of-thousands-file mirror needs a device to confirm.