Skip to content

Commit cc5466f

Browse files
authored
iOS: defer canvas resize on foreground to avoid iPad size flip (#4769)
1 parent 8bf246b commit cc5466f

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Ports/iOSPort/nativeSources/CodenameOne_GLAppDelegate.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,16 @@ - (void)cn1ApplicationWillEnterForeground
218218
com_codename1_impl_ios_IOSImplementation_applicationWillEnterForeground__(CN1_THREAD_GET_STATE_PASS_SINGLE_ARG);
219219
CodenameOne_GLViewController* vc = [CodenameOne_GLViewController instance];
220220
if (vc != nil) {
221-
[vc updateCanvas:YES];
221+
// Defer updateCanvas by one run-loop cycle so that UIKit has a chance to
222+
// settle the root view bounds after foreground transition. Calling this
223+
// too early can report the short edge for width/height on iPad, which
224+
// causes a transient wrong screen-size event between stop/start.
225+
dispatch_async(dispatch_get_main_queue(), ^{
226+
CodenameOne_GLViewController* deferredVc = [CodenameOne_GLViewController instance];
227+
if (deferredVc != nil) {
228+
[deferredVc updateCanvas:YES];
229+
}
230+
});
222231
}
223232
}
224233

0 commit comments

Comments
 (0)