Skip to content

Crossy Road: lay a shown window out in the next pass, and UIScreen's EDR headroom - #459

Merged
colemancda merged 3 commits into
masterfrom
display-first-tick
Nov 25, 2026
Merged

colemancda merged 3 commits into
masterfrom
display-first-tick

Conversation

@colemancda

Copy link
Copy Markdown
Member

Crossy Road 7.14.3 (Unity on Metal) aborted at start-up on the Duet 3:

*** Assertion failure in KeyboardDelegate Initialize, Keyboard.mm:365:
[KeyboardDelegate Initialize] called after creating keyboard

Unity's -createUI calls -makeKeyAndVisible, then +[KeyboardDelegate Initialize]. Perry laid the window out inside -makeKeyAndVisible, twice over: the display's first tick ran inline when the first window showed, and -makeKeyAndVisible called -layoutIfNeeded. -[UnityView layoutSubviews] makes the keyboard delegate (+Instance), so +Initialize found one and asserted. On iOS the window is laid out at the run loop's next commit, after the call returns, or every Unity game would hit this.

  • Display.startIfWanted starts the display timer instead of calling tick() inline, in both the compositor and X11 paths.
  • -[UIWindow makeKeyAndVisible] schedules a pass (Updates.schedule()) instead of layoutIfNeeded().
  • -[UIScreen potentialEDRHeadroom] and currentEDRHeadroom return 1, a standard-range display; Crossy Road aborted on the first next.

Risk: f4215f6 added the synchronous layout so Sonic & SEGA All-Stars Racing, which waits in its launch method for what its view's layoutSubviews sets up, would draw. If it waits by running the run loop, the pass still reaches it; if it spins without the run loop, it would stop drawing. Not retested here.

Tested on the Duet 3 with master (258bff1, built in the Parallels VM) plus these changes: Crossy Road starts and draws its title screen, and ran over 3 minutes. One earlier run segfaulted about 37 seconds in, after an ad SDK's interstitial callback; the next didn't, so there is no crash report yet. Play is untested.

…de makeKeyAndVisible

The first tick laid the app's views out while -makeKeyAndVisible was still running. iOS draws a shown window at the run loop's next turn.
…does

Unity's -[UnityView layoutSubviews] makes its keyboard delegate, and +[KeyboardDelegate Initialize], which Unity calls once -makeKeyAndVisible returns, asserts when one exists (Crossy Road). A program that waits in its launch method for its view's layout runs the run loop, which runs the pass.
@colemancda
colemancda merged commit f833c48 into master Nov 25, 2026
1 of 6 checks passed
@colemancda
colemancda deleted the display-first-tick branch November 25, 2026 22:27
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.

1 participant