Repository navigation
[iOS] Mark DisplayLinkManager.shared and init() @MainActor - #189815
Merged
cbracken merged 2 commits intoJul 22, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request applies @MainActor isolation to the DisplayLinkManager shared instance, its initializer, and the DisplayLinkManagerTest class to enforce main-thread execution at compile time for Swift callers. Feedback suggests reordering the @MainActor and @objc attributes on the shared instance alphabetically to comply with the Google Swift Style Guide.
Now that DisplayLinkManager is injected in nearly all use-cases and the `.shared` singleton is used at exactly 3 remaining call-sites, marks `.shared` and `init()` as `@MainActor` now that it's safe to do so. `DisplayLinkManager.init()` has always required betin called on the main thread since it reads `UIScreen.main`/`Bundle.main`, but that was only enforced by a runtime assert. which compiles out in most release configruations. The Swift compiler can now enforce a static, checkable contract instead. Actor-isolation checking is enforced in Swift 5.5+ regardless of strict-concurrency level or language mode, so this takes should take effect immediately given our current Swift 5 language mode/default concurrency checking not gated behind a migration. I've left the manual `assert(Thread.isMainThread, ...)` in place for now given the existing Obj-C use in `FlutterViewController` and `FlutterMetalLayer`. If we do eventually remove it, we should ensure that the runtime itself is enforcing this runtime behaviour first -- this is dependent on SDK version. I've also left the internal testing initializer non-isolated: it doesn't touch `UIScreen`/`Bundle.main`, so it has no main-thread requirement, and leaving it alone keeps the two tests that use it compiling unchanged. `DisplayLinkManagerTest.swift`'s `testSharedInstanceReturnsAValidValue` and `testDisplayConfigurationNotificationsAreHandledWithoutCrashing` both call `.shared` directly, so we needed to mark the test class `@MainActor`. XCTest already runs these on the main thread, so this is a no-op but makes the compiler (which doesn't know about XCTest's implementation) happy. Issue: flutter#175879 Issue: flutter#181684
cbracken
force-pushed
the
shared-displaylinkmanager-mainactor
branch
from
July 22, 2026 02:01
d8bfd4c to
74676ec
Compare
Contributor
|
autosubmit label was removed for flutter/flutter/189815, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label. |
This was referenced Jul 23, 2026
auto-submit Bot
pushed a commit
to flutter/packages
that referenced
this pull request
Jul 24, 2026
flutter/flutter@2a2a79d...b65f4d9 2026-07-24 [email protected] Add dart_runtime_service_vm_aot.dart.snapshot to the snapshot list in the macOS code signing configuration (flutter/flutter#189981) 2026-07-24 [email protected] Roll Fuchsia Test Scripts from wLST_A-xfOeGT_5mj... to E8hJ1AfK8CtGtaES0... (flutter/flutter#189956) 2026-07-23 [email protected] Consolidate AndroidArch and DarwinArch into CpuArch (flutter/flutter#189315) 2026-07-23 [email protected] Roll Dart SDK from 9258584f98b8 to e3fc57eae9eb (7 revisions) (flutter/flutter#189949) 2026-07-23 [email protected] [flutter_tools] Do not always wait for the full timeout when running Spotlight to locate Android Studio on macOS (flutter/flutter#189952) 2026-07-23 [email protected] Roll Skia from 1d8bf9270d8c to 6e9c4687c001 (15 revisions) (flutter/flutter#189954) 2026-07-23 [email protected] [flutter_tools] Initialize Cache.flutterRoot at the start of the upgrade_test suite (flutter/flutter#189937) 2026-07-23 [email protected] Parse AndroidX property in gradle.properties (flutter/flutter#188372) 2026-07-23 [email protected] [Impeller]Use the IO context for OpenGL program setup (flutter/flutter#185723) 2026-07-23 [email protected] Allow building projects lacking Runner.xcworkspace (flutter/flutter#186239) 2026-07-23 [email protected] [flutter_tools] Invalidate WebEntrypointTarget when plugin set changes (flutter/flutter#189460) 2026-07-23 [email protected] Bump devtools_shared to 13.1.0 (flutter/flutter#189507) 2026-07-23 [email protected] forceNdkDownload should skip configuring cmake when ndk-build is used (flutter/flutter#187201) 2026-07-23 [email protected] Disable execution order shuffling for the flutter_tools upgrade_test suite (flutter/flutter#189920) 2026-07-23 [email protected] Move WindowManager outside of WidgetsApp (flutter/flutter#188866) 2026-07-23 [email protected] Roll Skia from 3424966b8a2b to 1d8bf9270d8c (3 revisions) (flutter/flutter#189901) 2026-07-23 [email protected] Roll Fuchsia Linux SDK from GswhlPRO-D1qSNclx... to 9org0yL3yZkp80x5S... (flutter/flutter#189898) 2026-07-23 [email protected] Remove outdated logs that were added to track #172636 (flutter/flutter#189282) 2026-07-23 [email protected] Roll Skia from 5e183e5aeac5 to 3424966b8a2b (33 revisions) (flutter/flutter#189890) 2026-07-23 [email protected] [examples] Use super parameters in missed spots (flutter/flutter#186194) 2026-07-23 [email protected] [flutter_tools] Bound Spotlight mdfind execution with timeout on macOS (flutter/flutter#189461) 2026-07-23 [email protected] Fix non primary buttons not being captured on windows (flutter/flutter#188394) 2026-07-22 [email protected] Listen to log reader before VM Service and make delay configurable (flutter/flutter#187202) 2026-07-22 [email protected] Roll Dart SDK from 1e65011ee004 to 9258584f98b8 (7 revisions) (flutter/flutter#189883) 2026-07-22 [email protected] Adds skill for generating engine diffs for new releases. (flutter/flutter#189869) 2026-07-22 [email protected] [ios,macos] Add Swift Sourcekit LSP support (flutter/flutter#189761) 2026-07-22 [email protected] [iOS] Mark DisplayLinkManager.shared and init() @mainactor (flutter/flutter#189815) 2026-07-22 [email protected] Fix `Rect::ExpandToMinTransformedSize` to return the input rectangle when no expansion is needed, and remove 1-pixel roundrect to rect simplification (flutter/flutter#189808) 2026-07-22 [email protected] Skip emulator.getEmulators test (flutter/flutter#189879) 2026-07-22 [email protected] Fix null terminator in input truncates clipboard (flutter/flutter#188652) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now that DisplayLinkManager is injected in nearly all use-cases and the
.sharedsingleton is used at exactly 3 remaining call-sites, marks.sharedandinit()as@MainActornow that it's safe to do so.DisplayLinkManager.init()has always required betin called on the main thread since it readsUIScreen.main/Bundle.main, but that was only enforced by a runtime assert. which compiles out in most release configruations. The Swift compiler can now enforce a static, checkable contract instead. Actor-isolation checking is enforced in Swift 5.5+ regardless of strict-concurrency level or language mode, so this takes should take effect immediately given our current Swift 5 language mode/default concurrency checking not gated behind a migration.I've left the manual
assert(Thread.isMainThread, ...)in place for now given the existing Obj-C use inFlutterViewControllerandFlutterMetalLayer. If we do eventually remove it, we should ensure that the runtime itself is enforcing this runtime behaviour first -- this is dependent on SDK version.I've also left the internal testing initializer non-isolated: it doesn't touch
UIScreen/Bundle.main, so it has no main-thread requirement, and leaving it alone keeps the two tests that use it compiling unchanged.DisplayLinkManagerTest.swift'stestSharedInstanceReturnsAValidValueandtestDisplayConfigurationNotificationsAreHandledWithoutCrashingboth call.shareddirectly, so we needed to mark the test class@MainActor. XCTest already runs these on the main thread, so this is a no-op but makes the compiler (which doesn't know about XCTest's implementation) happy.No semantic changes to tests because there's no semantic change to the logic, and this is enforced by the complier itself.
Issue: #175879
Issue: #181684
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.