Skip to content

iOS: orientation-validate canvas size on iPad foreground (#4767)#4853

Merged
shai-almog merged 1 commit intomasterfrom
fix-4767-ipad-orientation-canvas
May 3, 2026
Merged

iOS: orientation-validate canvas size on iPad foreground (#4767)#4853
shai-almog merged 1 commit intomasterfrom
fix-4767-ipad-orientation-canvas

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • Restores the next-runloop deferral around updateCanvas: in cn1ApplicationWillEnterForeground so UIKit has a tick to settle view bounds after the snapshot rotation.
  • Cross-checks view.bounds against the windowScene's interfaceOrientation inside updateCanvas: and swaps the dimensions when they contradict it -- catches the failure even when the deferred call still fires before UIKit has restored bounds.

Why

Previous attempt (#4808 / a09b916) correctly filters viewWillTransitionToSize: during the background snapshot pass, but it then calls updateCanvas: synchronously inside cn1ApplicationWillEnterForeground. On iPad with UIScene, view.bounds is still in the snapshot orientation at that point, so the synchronous call republishes the swapped dimensions through screenSizeChanged -- the exact transient wrong size the user reports between stop and start in #4767.

The interface orientation reported by the windowScene is authoritative for what the user actually sees, so it can be used as a tiebreaker when the bounds and the orientation disagree.

Test plan

  • Verify on physical iPad in landscape: home → reopen no longer reports a portrait-orientation screenSizeChanged between stop and start.
  • Verify on physical iPad in portrait: home → reopen no longer reports a landscape-orientation screenSizeChanged between stop and start.
  • Confirm normal interactive rotation (viewWillTransitionToSize:) still propagates correctly.
  • Confirm iPhone behavior is unchanged.
  • Confirm UIScene-disabled (ios.uiscene=false) builds still behave correctly.

Fixes #4767

🤖 Generated with Claude Code

The previous attempt (a09b916) silenced viewWillTransitionToSize: during
background but then called updateCanvas: synchronously inside
cn1ApplicationWillEnterForeground. On iPad with UIScene, view.bounds can
still be in the snapshot orientation at that moment, so updateCanvas
republished the swapped dimensions through screenSizeChanged -- the same
behavior the issue reports as a transient wrong size between stop and
start.

This change combines two safeguards: it restores the next-runloop
deferral around the foreground updateCanvas call so UIKit has a tick to
settle the bounds, and it cross-checks the sampled size against the
windowScene's interfaceOrientation, swapping the dimensions when they
contradict it. The orientation is authoritative for what the user
actually sees, so this catches the failure even when the deferred call
still fires before UIKit has fully restored bounds.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 3, 2026

✅ Continuous Quality Report

Test & Coverage

Static Analysis

  • SpotBugs [Report archive]
    • ByteCodeTranslator: 0 findings (no issues)
    • android: 0 findings (no issues)
    • codenameone-maven-plugin: 0 findings (no issues)
    • core-unittests: 0 findings (no issues)
    • ios: 0 findings (no issues)
  • PMD: 0 findings (no issues) [Report archive]
  • Checkstyle: 0 findings (no issues) [Report archive]

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 3, 2026

Compared 79 screenshots: 79 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 526 seconds

Build and Run Timing

Metric Duration
Simulator Boot 164000 ms
Simulator Boot (Run) 3000 ms
App Install 30000 ms
App Launch 31000 ms
Test Execution 309000 ms

@shai-almog shai-almog merged commit ff335a5 into master May 3, 2026
15 checks passed
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.

Ipad frame size after restart

1 participant