Skip to content

Commit

Permalink
fix(ios): fix debug issues with scenes (#13979)
Browse files Browse the repository at this point in the history
* Revert "Revert "feat(ios): support multi-scene applications (#13941)""

This reverts commit 4a1d20f.

* fix: defer loading kroll-core to scene initialization
  • Loading branch information
hansemannn committed Jan 30, 2024
1 parent 4e5ca53 commit 8bcd5c3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 25 deletions.
9 changes: 1 addition & 8 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.h
Expand Up @@ -13,17 +13,10 @@
#import "TiRootViewController.h"
#import <JavaScriptCore/JavaScriptCore.h>

extern BOOL applicationInMemoryPanic; // TODO: Remove in SDK 9.0+

// TODO: Remove in SDK 9.0+
TI_INLINE void waitForMemoryPanicCleared() //WARNING: This must never be run on main thread, or else there is a risk of deadlock!
{
}

/**
TiApp represents an instance of an application. There is always only one instance per application which could be accessed through <app> class method.
*/
@interface TiApp : TiHost <UIApplicationDelegate, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDownloadDelegate, UNUserNotificationCenterDelegate> {
@interface TiApp : TiHost <UIApplicationDelegate, NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDownloadDelegate, UNUserNotificationCenterDelegate, UIWindowSceneDelegate> {
UIWindow *window;
UIImageView *loadView;
UIView *splashScreenView;
Expand Down
39 changes: 22 additions & 17 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiApp.m
Expand Up @@ -33,11 +33,6 @@

#define SHUTDOWN_TIMEOUT_IN_SEC 3

BOOL applicationInMemoryPanic = NO; // TODO: Remove in SDK 9.0+

// TODO: Remove in SDK 9.0+
TI_INLINE void waitForMemoryPanicCleared(void); //WARNING: This must never be run on main thread, or else there is a risk of deadlock!

@interface TiApp ()
- (void)checkBackgroundServices;
- (void)appBoot;
Expand Down Expand Up @@ -327,15 +322,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[[TiLogServer defaultLogServer] start];
}

// Initialize the root-window
window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

// Initialize the launch options to be used by the client
launchOptions = [[NSMutableDictionary alloc] initWithDictionary:launchOptions_];

// Initialize the root-controller
[self initController];

// If we have a APNS-UUID, assign it
NSString *apnsUUID = [[NSUserDefaults standardUserDefaults] stringForKey:@"APNSRemoteDeviceUUID"];
if (apnsUUID != nil) {
Expand Down Expand Up @@ -427,12 +416,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// If a "application-launch-url" is set, launch it directly
[self launchToUrl];

// Boot our kroll-core
[self boot];

// Create application support directory if not exists
[self createDefaultDirectories];

return YES;
}

Expand Down Expand Up @@ -1235,6 +1218,28 @@ - (KrollBridge *)krollBridge
return kjsBridge;
}

#pragma mark UIWindowSceneDelegate

- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options
{
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}

- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions
{
// Initialize the root-window
window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];

// Initialize the root-controller
[self initController];

// Boot our kroll-core
[self boot];

// Create application support directory if not exists
[self createDefaultDirectories];
}

#pragma mark Background Tasks

- (void)beginBackgrounding
Expand Down
17 changes: 17 additions & 0 deletions iphone/iphone/Titanium.plist
Expand Up @@ -78,5 +78,22 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>TiApp</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>
17 changes: 17 additions & 0 deletions support/iphone/Info.plist
Expand Up @@ -36,5 +36,22 @@
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>TiApp</string>
</dict>
</array>
</dict>
</dict>
</dict>
</plist>

0 comments on commit 8bcd5c3

Please sign in to comment.