Skip to content

Release hot-reload input resources and retired callbacks - #1018

Open
bartasc4 wants to merge 1 commit into
JingMatrix:masterfrom
bartasc4:fix/hot-reload-resource-lifetime
Open

bartasc4 wants to merge 1 commit into
JingMatrix:masterfrom
bartasc4:fix/hot-reload-resource-lifetime

Conversation

@bartasc4

@bartasc4 bartasc4 commented Oct 18, 2026 •

Copy link
Copy Markdown

After a hot reload, an idle executor thread and retained inactive hook handles/callback parameters can outlive their useful work. Refused or failed requests can also leave received DEX resources unconsumed. This change releases those framework-owned resources while allowing in-flight callbacks to finish on the generation they entered.

  • Use a serial worker that exits when its queue drains and releases the queue storage. Preserve FIFO dispatch and recover from task, reporter and thread-start failures.
  • Consume DEX inputs in order and release every received handle/mapping on success, refusal and failure. Report cleanup failures without losing whether the generation already changed.
  • Release inactive handles' callback records, avoid retaining an old generation through reload parameters, and skip empty callback-snapshot allocations. Preserve hook identities, atomic replacement and in-flight snapshots.

Applies directly to master. This is resource-lifetime cleanup; it does not change the reload negotiation policy or replace #992. It is independent of daemon reconnection #1017 and #1012; the three changes were also built/tested together.

Validation and limits

Validation: clean-source Kotlin and four-ABI native builds; host tests exercise production classes and native callback operations, including 3,000 replacements, 8,000 concurrent queue submissions, 100 drained batches, and DEX failure cleanup. On Android 12 with NeoZygisk, a local validation build completed two consecutive reloads in one application process, then two more after a KernelSU emulated soft reboot. Retained old callback parameters did not prevent retired module/loader weak references from clearing; in-flight callbacks completed, the idle reload worker exited, and the process FD count stayed flat. The clean PR sources were built separately from that local validation build.

Limits: host SharedMemory tests use controlled doubles. The change releases framework-owned references and DEX inputs; ART controls reclamation of its own DEX memory. It does not unload native module libraries or reclaim objects deliberately retained by module/application code.

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