Fix native iOS view controller startup#8524
Open
yutaokuyama wants to merge 1 commit into
Open
Conversation
Custom app delegates start UIApplicationMain before an OF view controller installs its app. Calling the single-argument ofRunApp overload from view setup re-enters the iOS main loop; since openframeworks#8148, returning from that loop also runs exit() and removes the newly registered app and listeners. Register the app against the recreated window with the window-specific overload so the active UIKit loop is not started or exited again.
Member
|
Thank you! Will test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes openFrameworks apps embedded in a native UIKit view-controller hierarchy through a custom app delegate.
When
startAppWithDelegate()is used withofxiOSViewControllerorofxiOSGLKViewController, the embedded app is removed from the main loop immediately after registration and does not receivesetup(),update(), ordraw()callbacks.Cause
The view recreates the OF main loop and window, then registers the embedded app with:
ofRunApp(app);This overload also calls
ofRunMainLoop(). SinceUIApplicationMainis already running,startAppWithDelegate()returns immediately through itsbAppCreatedguard.Since #8148, returning from the window loop calls
ofMainLoop::exit(), which removes the app and its listeners.Fix
Register the app with the recreated window without starting the main loop again:
ofRunApp(window, std::static_pointer_cast<ofBaseApp>(app));The same change is applied to the EAGL and GLK implementations.
The standard iOS startup path is unaffected because it does not enter this code path.
Testing
ofxiOSViewController. Before the fix, UIKit installs the view controller but no OF callbacks are received. After the fix,setup(),update(), anddraw()all run.master, where the affected code paths are unchanged.