Skip to content

iOS: honor SDL_HINT_MAIN_CALLBACK_RATE via CADisplayLink - #16060

Open
voki-andreev-a wants to merge 2 commits into
libsdl-org:mainfrom
yozka:ios-main-callback-rate
Open

iOS: honor SDL_HINT_MAIN_CALLBACK_RATE via CADisplayLink#16060
voki-andreev-a wants to merge 2 commits into
libsdl-org:mainfrom
yozka:ios-main-callback-rate

Conversation

@voki-andreev-a

Copy link
Copy Markdown
Contributor
  • I confirm that I am the author of this code and release it to the SDL project under the Zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

Description

On iOS, main callbacks are driven by a CADisplayLink, so SDL_HINT_MAIN_CALLBACK_RATE was ignored (unlike the generic path, which paces with SDL_DelayPrecise).

This change registers an SDL_AddHintCallback for SDL_HINT_MAIN_CALLBACK_RATE and, when a positive rate is set, applies it to the display link:

  • iOS 15+ / tvOS 15+: preferredFrameRateRange via CAFrameRateRangeMake((rate * 2) / 3, rate, rate)
  • older OS versions: preferredFramesPerSecond

Default behavior is unchanged when the hint is unset or "0" (including the existing ProMotion high-refresh setup). The hint can still be changed at runtime.

Note: the system may still choose a nearby supported frame rate (e.g. divisors of 60/120 Hz), as with other CADisplayLink preferences.

Existing Issue(s)

Fixes #15277

@slouken
slouken requested a review from icculus July 26, 2026 19:00
@slouken slouken modified the milestones: 3.4.14, 3.6.0 Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDL_HINT_MAIN_CALLBACK_RATE on iOS

2 participants