Skip to content

[iOS] Migrate VSyncClient and DisplayLinkManager to Swift#186225

Closed
cbracken wants to merge 2 commits into
flutter:masterfrom
cbracken:swift-vsyncclient
Closed

[iOS] Migrate VSyncClient and DisplayLinkManager to Swift#186225
cbracken wants to merge 2 commits into
flutter:masterfrom
cbracken:swift-vsyncclient

Conversation

@cbracken

@cbracken cbracken commented May 8, 2026

Copy link
Copy Markdown
Member

Migrates FlutterVSyncClient and FlutterDisplayLinkManager from Objective-C to Swift.

(void) casts were added to OCMock usages of DisplayLinkManager because by default Swift warns on unused results and overall, that behaviour is better in real production code.

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 8, 2026 00:51
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 8, 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 8, 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 migrates the FlutterVSyncClient and FlutterDisplayLinkManager from Objective-C to Swift, introducing VSyncClient.swift and updating associated build files and tests. The review feedback focuses on adhering to the style guide by adding documentation to public members, refining access modifiers for internal properties and methods, and improving the visibility of constants for Objective-C compatibility.

Comment thread engine/src/flutter/shell/platform/darwin/ios/framework/Source/VSyncClient.swift Outdated
Comment thread engine/src/flutter/shell/platform/darwin/ios/framework/Source/VSyncClient.swift Outdated
Comment thread engine/src/flutter/shell/platform/darwin/ios/framework/Source/VSyncClient.swift Outdated
@cbracken cbracken force-pushed the swift-vsyncclient branch from 03d3366 to c4a0bd4 Compare May 8, 2026 00:53
@github-actions github-actions Bot removed the CICD Run CI/CD label May 8, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 8, 2026
@cbracken cbracken force-pushed the swift-vsyncclient branch from 92e3e6b to b440121 Compare May 8, 2026 01:09
@github-actions github-actions Bot removed the CICD Run CI/CD label May 8, 2026
// before that line can be deleted.
//
// If we intend to support configurable preferred FPS, then we should provide API for it. We
// should delete this code either way.

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.

Note: this is ported line-for-line from the Obj-C implementation. We should still fix this but it's orthogonal to this change.

import UIKit

@objc(FlutterDisplayLinkManager)
public class DisplayLinkManager: NSObject {

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.

Nit: move this to a separate DisplayLinkManager.swift?

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.

also need doc comment

@objc(FlutterDisplayLinkManager)
public class DisplayLinkManager: NSObject {

/// Info.plist key enabling the full range of ProMotion refresh rates for CADisplayLink callbacks

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.

enabling -> disabling?


/// Whether the max refresh rate on iPhone ProMotion devices are enabled. This reflects the value
/// of `CADisableMinimumFrameDurationOnPhone` in the info.plist file. On iPads that support
/// ProMotion, the max refresh rate is always enabled.

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.

is there a way to disable it on ipad, via info.plist?

) {
self.callback = callback
self.isVariableRefreshRateEnabled = isVariableRefreshRateEnabled
self.refreshRate = maxRefreshRate

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.

is self.refreshRate used?

cbracken added 2 commits May 8, 2026 15:14
Migrates FlutterVSyncClient and FlutterDisplayLinkManager from Objective-C to
Swift.

(void) casts were added to OCMock usages of DisplayLinkManager because
by default Swift warns on unused results and overall, that behaviour is
better in real production code.

Issue: flutter#112232
@cbracken cbracken force-pushed the swift-vsyncclient branch from b440121 to 8b5df75 Compare May 8, 2026 06:15
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label May 8, 2026
@hellohuanlin

Copy link
Copy Markdown
Contributor

@cbracken let me know if this is ready for another review

@cbracken cbracken closed this May 23, 2026
@cbracken

Copy link
Copy Markdown
Member Author

I've rebased on top of my reland of the Obj-C-ified FlutterVSyncClient and cleaned up in #187001

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.

3 participants