Skip to content

[pigeon] Swift FlutterApi async methods need @MainActor annotation #192199

Closed
flutter/packages
#12729

Description

@stuartmorgan-g

I tried adopting the new async support as part of completing the google_maps_flutter migration to Swift, and while doing manual testing I was seeing engine logging telling me that I (via Pigeon) was sending messages from the wrong thread.

I'm still new to Swift's new concurrency model, but based on Gemini debugging (which I believe is correct based on my follow-up reading), the issue is that when there is no actor annotation, the default behavior is that any await call can jump threads. So even if clients are careful to call FlutterApi calls from the main thread, as soon as they await any given FlutterApi method call, it's likely to jump to a background thread, and send the message from there.

I verified locally that annotating the entire *Protocol generated for the FlutterApi as @MainActor fixed it.

Activity

  1. added
    packageflutter/packages repository. See also p: labels.
    p: pigeonrelated to pigeon messaging codegen tool
    P1High-priority issues at the top of the work list
    on Sep 2, 2026
  2. github-actions commented on Sep 25, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  3. locked as resolved and limited conversation to collaborators on Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listp: pigeonrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions