Skip to content

iOS: flush the core off the main thread under a background task - #141

Open
katulevskiy wants to merge 3 commits into
mirror/upstream-mainfrom
mirror/upstream-pr/624
Open

katulevskiy wants to merge 3 commits into
mirror/upstream-mainfrom
mirror/upstream-pr/624

Conversation

@katulevskiy

Copy link
Copy Markdown
Owner

Upstream mirror

Source: zeronsh#624
Original author: @katulevskiy
Original revision: d4e5454f2cecdef93f13057a279260317ebedf3c

This PR is an isolated Contribution Manager pilot mirror. Its reviews, checks and merge state are separate from upstream. An empty [skip ci] commit suppresses automatic bulk CI; the code tree matches the imported upstream revision.


Summary

  • didEnterBackground called CoreClient.onBackground() inline on the main thread with no background task assertion. The old SwiftUI app held a beginBackgroundTask around its flush; the UIKit rewrite dropped it.
  • The flush now runs on a serial queue under beginBackgroundTask, ended when the flush finishes or in the expiration handler. willEnterForeground runs onForeground() on the same queue, so a quick return to the app can't overtake a running flush.
  • The Rust side already skips clean state (Persister::flush returns when generation == saved, and the registry flush is gated on registry_dirty), so there is no core change. A new test pins that behaviour.
  • FFI surface and generated bindings are unchanged.
  • Worth a close look: in willEnterForeground, refreshWorkspace() still runs immediately while onForeground() is now queued. Before, the core call finished first. If refreshWorkspace() depends on it, that ordering needs another look.
  • The Swift change hasn't been built locally, so it relies on the iOS CI job.

katulevskiy and others added 2 commits September 28, 2026 21:07
…tion

didEnterBackground ran CoreClient.onBackground() inline on the main thread
with no UIKit background-task assertion, so a slow flush blocked the scene
callback and nothing kept iOS from suspending the process once it returned.
The old SwiftUI app held a beginBackgroundTask around its flush; the UIKit
rewrite dropped it.

Run the lifecycle calls on a serial queue (so a quick foreground cannot
overtake a running flush) and hold beginBackgroundTask until the flush is
done; the expiration handler ends the task. The FFI surface is unchanged.

The Rust side already skips clean state (Persister::flush returns when
generation == saved; the registry flush is gated on registry_dirty), so no
core change is needed. Pin that with a test, since backgrounding cost
depends on it.
@contribution-manager-katulevskiy contribution-manager-katulevskiy Bot added the review:needs-triage Managed by Contribution Manager label Oct 6, 2026
@contribution-manager-katulevskiy

contribution-manager-katulevskiy Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Contribution Manager

needs triage · medium risk · untriaged

Open review workspace · Revision 26cccf16

Next actions:

  • Direction decision needed
  • Scope, risk, and platform triage needed
  • Independent code review needed
  • Required check: core-tests (missing)

This summary is maintained by the review app. Decisions and test evidence are recorded in the workspace; the app does not merge PRs.

@contribution-manager-katulevskiy contribution-manager-katulevskiy Bot added cm:inbox Contribution Manager: waiting for triage and removed review:needs-triage Managed by Contribution Manager labels Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cm:inbox Contribution Manager: waiting for triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant