Skip to content

fix(android): Backport worker teardown mitigation - #4096

Draft
buenaflor wants to merge 3 commits into
v9from
fix/v9-android-worker-detach-resume
Draft

buenaflor wants to merge 3 commits into
v9from
fix/v9-android-worker-detach-resume

Conversation

@buenaflor

@buenaflor buenaflor commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Backport #4095 to v9, based on 9.30.1. Stop the Android core worker on Flutter detached, restart it on resumed for retained engines, and replace its closeOnOwnerExit() registration.

Drain queued native operations before caller-isolate fallback or replacement startup, preserving user/context update ordering. Preserve calls accepted before close and propagate delayed envelope submission through the native adapter. The backport retains v9's envelope and JNI APIs. Android beta example-build and integration jobs are excluded; other beta platforms remain enabled.

💡 Motivation and Context

Refs #4092 and #4095.

This is a best-effort mitigation, not a confirmed fix for the Vulkan crash. Lifecycle delivery and worker exit before native engine teardown are not guaranteed. Hosts that never deliver detached can retain their workers after owner exit. The source PR's Vulkan comparison did not reproduce the original abort, and busy workers could outlive teardown; crash prevention on affected physical hardware remains unproven.

💚 How did you test it?

  • All 74 focused worker, native adapter, isolate, and binding tests pass on Flutter 3.47.0. All 50 worker, native adapter, and isolate tests pass on the minimum Flutter 3.24.0 / Dart 3.5.0 toolchain.
  • Minimum-version testing required locally regenerating the release's incompatible mocks. Generated changes were restored and are excluded.
  • Real JNI regression coverage checks a cleared native user after retiring work, including concurrent close. The lifecycle integration test uses platform lifecycle messages to synthesize valid intermediate transitions.
  • All three handoff/lifecycle integration cases pass on an Android API 36 emulator with v9's native SDK. Package analysis and formatting checks pass.

📝 Checklist

  • Reviewed the backport against fix(android): Mitigate worker teardown timing #4095 and v9's APIs
  • Added handoff, capture-completion, and concurrent-close regression coverage
  • No new configuration option or public API export
  • No new PII collection
  • Validate the original Vulkan failure on affected hardware

Backport detached/resumed worker cleanup to v9.30.1.
Preserve the existing v9 envelope API and regression coverage.

This is best effort, not a confirmed fix for the Vulkan crash.

Refs #4092, #4095

(cherry picked from commit a08998c)

Co-Authored-By: Codex <noreply@openai.com>
@github-actions

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Fixes

  • (android) Backport worker teardown mitigation by buenaflor in #4096

🤖 This preview updates automatically when you update the PR.

Run Android example and integration jobs on stable.
Keep beta coverage for the remaining platforms.

Co-Authored-By: Codex <noreply@openai.com>
@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.46%. Comparing base (e315482) to head (68583dd).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##               v9    #4096      +/-   ##
==========================================
+ Coverage   88.17%   92.46%   +4.29%     
==========================================
  Files         347      114     -233     
  Lines       12955     4434    -8521     
==========================================
- Hits        11423     4100    -7323     
+ Misses       1532      334    -1198     
Flag Coverage Δ
sentry ?
sentry_dio ?
sentry_drift ?
sentry_file ?
sentry_firebase_remote_config 100.00% <ø> (ø)
sentry_flutter 92.17% <ø> (-0.29%) ⬇️
sentry_grpc ?
sentry_hive ?
sentry_isar ?
sentry_link ?
sentry_logging ?
sentry_sqflite ?
sentry_supabase 97.27% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Drain queued native updates before fallback calls or replacement workers.
Propagate deferred envelope completion and preserve accepted operations
when close overlaps worker retirement.

Drive integration lifecycle changes through the platform channel.

Refs #4092

Co-Authored-By: Codex <noreply@openai.com>

This branch has not been deployed

No deployments
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