From 8c5f092345334a3cf8977826e774d396da42570a Mon Sep 17 00:00:00 2001 From: yutaokuyama Date: Wed, 15 Jul 2026 11:10:20 +0900 Subject: [PATCH] Fix native iOS view controller startup 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 #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. --- addons/ofxiOS/src/core/ofxiOSEAGLView.mm | 5 ++++- addons/ofxiOS/src/core/ofxiOSGLKView.mm | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/ofxiOS/src/core/ofxiOSEAGLView.mm b/addons/ofxiOS/src/core/ofxiOSEAGLView.mm index f1faae7b8e0..a093a4c9f97 100644 --- a/addons/ofxiOS/src/core/ofxiOSEAGLView.mm +++ b/addons/ofxiOS/src/core/ofxiOSEAGLView.mm @@ -99,7 +99,10 @@ - (void)setup { window = dynamic_pointer_cast(ofCreateWindow(windowSettings)); - ofRunApp(app); + // UIKit already owns the application loop when a custom app delegate + // installs this view. Register the app with the recreated window + // without starting the main loop again. + ofRunApp(window, std::static_pointer_cast(app)); } if(window->isProgrammableRenderer() == true) { diff --git a/addons/ofxiOS/src/core/ofxiOSGLKView.mm b/addons/ofxiOS/src/core/ofxiOSGLKView.mm index 04e83cde705..666d2211a4e 100644 --- a/addons/ofxiOS/src/core/ofxiOSGLKView.mm +++ b/addons/ofxiOS/src/core/ofxiOSGLKView.mm @@ -99,7 +99,10 @@ - (void)setup { window = dynamic_pointer_cast(ofCreateWindow(windowSettings)); - ofRunApp(app); + // UIKit already owns the application loop when a custom app delegate + // installs this view. Register the app with the recreated window + // without starting the main loop again. + ofRunApp(window, std::static_pointer_cast(app)); } if(window->isProgrammableRenderer() == true) {