mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-08 23:54:39 +00:00
A self-heal reset()/resetWithCleanState() (and the lifecycle serialization added in the previous commit) can only recover Tor if initialize() actually returns. ArtiNative.initialize() calls TorClient::create_bootstrapped, which on a hostile network (unreachable guards, wiped consensus) retries internally for many minutes. While it blocks it holds lifecycleMutex, so the watchdog's reset can never run — Tor stays wedged at Connecting. Wrap create_bootstrapped in a 60s tokio::time::timeout. On timeout the future is dropped (tearing down the half-built client) and initialize() returns -4; the JNI ABI is unchanged (still one String arg), so the checked-in CI host .so and TorArtiNativeIntegrationTest keep working without a rebuild. TorService treats -4 specially: drop the init flag and leave status Connecting (don't wipe+retry inline under the lock, don't go Off) so TorManager's self-heal watchdog resets and re-inits on its own cadence, and connectionFailure can still surface the "use regular connection" dialog. Rebuilt libarti_android.so for arm64-v8a + x86_64. Verified on device: a no-network cold-start bootstrap timed out at exactly 60s (previously hung 7+ min), released the lock, and on network restore the watchdog re-init'd and Tor reached Active. Addresses #3225. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>