Skip to content

Background crawls stall: no foreground service or wakelock #74

Description

@xroche

Switching away from the app during a mirror makes the crawl appear to pause. It's not the app pausing it — onPause() sets a paused flag (HTTrackActivity.java:3053) that is never read, so nothing in the crawl path acts on it. The crawl runs as a plain background AsyncTask thread (engine.main(), HTTrackActivity.java:1302) with no foreground service and no wakelock anywhere in app/src/main/.

So once backgrounded the crawl is at the mercy of Android background management — CPU/network throttling, Doze/App Standby with the screen off, and process freeze/kill under memory pressure. Progress stalls and resumes on return to foreground, worst with the screen off.

The code already flags this as known (HTTrackActivity.java:2356-2358): reliability while backgrounded "relies on us staying the MRU cached process. A foreground service (needs an Android-14 FGS type) is a future step."

Fix: run the crawl under a foreground service with an Android-14 FGS type (dataSync) and a progress notification, plus a partial wakelock held for the duration of the crawl. Dead-code cleanup of the unused paused flag can ride along.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions