Skip to content

Run Cleanup delete and Browse-All index rebuild off the UI thread#18

Merged
xroche merged 3 commits into
masterfrom
fix/bulk-io-off-thread
Jul 18, 2026
Merged

Run Cleanup delete and Browse-All index rebuild off the UI thread#18
xroche merged 3 commits into
masterfrom
fix/bulk-io-off-thread

Conversation

@xroche

@xroche xroche commented Jul 18, 2026

Copy link
Copy Markdown
Owner

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.

xroche and others added 3 commits July 18, 2026 18:56
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
@xroche
xroche merged commit 0c878da into master Jul 18, 2026
5 checks passed
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.

1 participant