Skip to content

[iOS] Migrate to explicit VSyncClient initialisers - #185916

Merged
cbracken merged 1 commit into
flutter:masterfrom
cbracken:remove-explicit-initialisers
May 5, 2026
Merged

[iOS] Migrate to explicit VSyncClient initialisers#185916
cbracken merged 1 commit into
flutter:masterfrom
cbracken:remove-explicit-initialisers

Conversation

@cbracken

@cbracken cbracken commented May 2, 2026

Copy link
Copy Markdown
Member

Migrates FlutterVSyncClient to use explicit designated initialisers and removes the convenience initialisers that implicitly injected refresh rate details from FlutterDisplayLinkManager.

Previously, FlutterVSyncClient provided initializers that defaulted the refresh rate settings by reading directly from FlutterDisplayLinkManager which created an implicit dependency on global state and made the class harder to test in isolation or with specific configurations.

Issue: #112232

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-assist bot 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.

@cbracken
cbracken requested a review from a team as a code owner May 2, 2026 03:16
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 2, 2026
@github-actions github-actions Bot added platform-ios iOS applications specifically engine flutter/engine related. See also e: labels. team-ios Owned by iOS platform team labels May 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes convenience initializers for FlutterVSyncClient, requiring the use of the designated initializer with explicit variable refresh rate and max refresh rate parameters. This change is implemented across FlutterKeyboardInsetManager, FlutterViewController, and vsync_waiter_ios, with updates to the corresponding unit tests. Feedback recommends using std::move for the callback in vsync_waiter_ios.mm to prevent unnecessary copies and updating the documentation for the modified initializers to include descriptions for the new parameters as required by the style guide.

I am having trouble creating individual review comments. Click here to see my feedback.

engine/src/flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm (28)

medium

The callback lambda should be moved into the initializer to avoid an unnecessary copy, consistent with the previous implementation in FlutterVSyncClient.mm.

                                                     callback:std::move(callback)];

engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterVSyncClient.h (69-76)

medium

With the removal of the convenience initializer, the designated initializer initWithTaskRunner:isVariableRefreshRateEnabled:maxRefreshRate:callback: is now the primary public entry point. It should be updated to include full documentation for its parameters, adhering to the Flutter style guide for public members.

References
  1. All public members should have documentation. Documentation should be useful: Explain the why and the how. (link)

engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterVSyncClient+FML.h (17-18)

medium

The documentation for the remaining internal initializer should be updated to describe the new parameters isVariableRefreshRateEnabled and maxRefreshRate, as the current description is now incomplete.

References
  1. All public members should have documentation. Documentation should be useful: Explain the why and the how. (link)

@cbracken
cbracken force-pushed the remove-explicit-initialisers branch from e9bff8a to e121a23 Compare May 2, 2026 03:27
@github-actions github-actions Bot removed the CICD Run CI/CD label May 2, 2026
@cbracken

cbracken commented May 2, 2026

Copy link
Copy Markdown
Member Author

engine/src/flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm (28)

medium

The callback lambda should be moved into the initializer to avoid an unnecessary copy, consistent with the previous implementation in FlutterVSyncClient.mm.

                                                     callback:std::move(callback)];

Good point. Done.

engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterVSyncClient.h (69-76)

medium

With the removal of the convenience initializer, the designated initializer initWithTaskRunner:isVariableRefreshRateEnabled:maxRefreshRate:callback: is now the primary public entry point. It should be updated to include full documentation for its parameters, adhering to the Flutter style guide for public members.

Bad feedback. It's already documented.

engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterVSyncClient+FML.h (17-18)

medium

The documentation for the remaining internal initializer should be updated to describe the new parameters isVariableRefreshRateEnabled and maxRefreshRate, as the current description is now incomplete.

Bad feedback. This is also already documented and I'm going to migrate the last use of it in the next PR and delete it anyways.

@cbracken cbracken added the CICD Run CI/CD label May 2, 2026
@cbracken
cbracken requested a review from hellohuanlin May 2, 2026 03:58
Migrates `FlutterVSyncClient` to use explicit designated initialisers
and removes the convenience initialisers that implicitly injected
refresh rate details from `FlutterDisplayLinkManager`.

Previously, `FlutterVSyncClient` provided initializers that defaulted
the refresh rate settings by reading directly from
`FlutterDisplayLinkManager` which created an implicit dependency on
global state and made the class harder to test in isolation or with
specific configurations.

Issue: flutter#112232
@cbracken
cbracken force-pushed the remove-explicit-initialisers branch from e121a23 to 07ac300 Compare May 2, 2026 05:39
@github-actions github-actions Bot removed the CICD Run CI/CD label May 2, 2026
@cbracken cbracken added the CICD Run CI/CD label May 2, 2026
_keyboardAnimationVSyncClient = [[FlutterVSyncClient alloc]
initWithTaskRunner:delegate.engine.uiTaskRunner
isVariableRefreshRateEnabled:FlutterDisplayLinkManager.maxRefreshRateEnabledOnIPhone
maxRefreshRate:FlutterDisplayLinkManager.displayRefreshRate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanity check - This maxRefreshRate means the resolved max refresh rate, not the physical capability of the screen, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct yep -- don't want to lose the approval bit but will send a followup that adds that to the docs! Thanks for calling it out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants