Skip to content

Commit

Permalink
Bugfix FXIOS-9533 Temporarily disable multi-window, add scene and UUI…
Browse files Browse the repository at this point in the history
…D logging (#21095) (#21098)

* [9533] Temporarily disable multi-window support

* [9533] Logging for scene lifecycle and UUID logic

(cherry picked from commit 04d72e5)

Co-authored-by: mattreaganmozilla <[email protected]>
  • Loading branch information
mergify[bot] and mattreaganmozilla authored Jul 18, 2024
1 parent 53bcf57 commit c0e366f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
7 changes: 7 additions & 0 deletions firefox-ios/Client/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
options connectionOptions: UIScene.ConnectionOptions
) {
guard !AppConstants.isRunningUnitTest else { return }
logger.log("SceneDelegate: will connect to session", level: .info, category: .lifecycle)

// Add hooks for the nimbus-cli to test experiments on device or involving deeplinks.
if let url = connectionOptions.urlContexts.first?.url {
Expand All @@ -51,6 +52,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
}

func sceneDidDisconnect(_ scene: UIScene) {
let logUUID = sceneCoordinator?.windowUUID.uuidString ?? "<nil>"
logger.log("SceneDelegate: scene did disconnect. UUID: \(logUUID)", level: .info, category: .lifecycle)
// Handle clean-up here for closing windows on iPad
guard let sceneCoordinator = (scene.delegate as? SceneDelegate)?.sceneCoordinator else { return }

Expand All @@ -73,6 +76,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
/// or other activities that need to begin.
func sceneDidBecomeActive(_ scene: UIScene) {
guard !AppConstants.isRunningUnitTest else { return }
let logUUID = sceneCoordinator?.windowUUID.uuidString ?? "<nil>"
logger.log("SceneDelegate: scene did become active. UUID: \(logUUID)", level: .info, category: .lifecycle)

// Resume previously stopped downloads for, and on, THIS scene only.
if let uuid = sceneCoordinator?.windowUUID {
Expand All @@ -87,6 +92,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
/// Use this method to reduce the scene's memory usage, clear claims to resources & dependencies / services.
/// UIKit takes a snapshot of the scene for the app switcher after this method returns.
func sceneDidEnterBackground(_ scene: UIScene) {
let logUUID = sceneCoordinator?.windowUUID.uuidString ?? "<nil>"
logger.log("SceneDelegate: scene did enter background. UUID: \(logUUID)", level: .info, category: .lifecycle)
if let uuid = sceneCoordinator?.windowUUID {
downloadQueue.pauseAll(for: uuid)
}
Expand Down
13 changes: 12 additions & 1 deletion firefox-ios/Client/Application/WindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,22 @@ final class WindowManagerImplementation: WindowManager, WindowTabsSyncCoordinato
// Fetch available window data on disk, and remove any already-opened windows
// or UUIDs that are already reserved and in the process of opening.
let openWindowUUIDs = windows.keys
let filteredUUIDs = tabDataStore.fetchWindowDataUUIDs().filter {
let onDiskUUIDs = tabDataStore.fetchWindowDataUUIDs()
let filteredUUIDs = onDiskUUIDs.filter {
!openWindowUUIDs.contains($0) && !reservedUUIDs.contains($0)
}

let onDiskUUIDLog = onDiskUUIDs.map({ $0.uuidString.prefix(8) }).joined(separator: ", ")
let reserveLog = reservedUUIDs.map({ $0.uuidString.prefix(8) }).joined(separator: ", ")
let openLog = openWindowUUIDs.map({ $0.uuidString.prefix(8) }).joined(separator: ", ")
logger.log("WindowManager: reserve next UUID. Disk: \(onDiskUUIDLog). Reserved: \(reserveLog). Open: \(openLog)",
level: .debug,
category: .window)

let result = nextWindowUUIDToOpen(filteredUUIDs)
logger.log("WindowManager: reserve next UUID result = \(result.uuid.uuidString) Is new?: \(result.isNew)",
level: .debug,
category: .window)
let resultUUID = result.uuid
if result.isNew {
// Be sure to add any brand-new windows to our ordering preferences
Expand Down
4 changes: 3 additions & 1 deletion firefox-ios/Client/Coordinators/Scene/SceneCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class SceneCoordinator: BaseCoordinator, LaunchCoordinatorDelegate, LaunchFinish
// The logic is handled by `reserveNextAvailableWindowUUID`, but this is the point at which a window's UUID
// is set; this same UUID will be injected throughout several of the window's related components
// such as its TabManager instance, which also has the window UUID property as a convenience.
self.windowUUID = windowManager.reserveNextAvailableWindowUUID()
let uuid = windowManager.reserveNextAvailableWindowUUID()
self.windowUUID = uuid
self.window = sceneSetupHelper.configureWindowFor(scene,
windowUUID: windowUUID,
screenshotServiceDelegate: screenshotService)
Expand All @@ -36,6 +37,7 @@ class SceneCoordinator: BaseCoordinator, LaunchCoordinatorDelegate, LaunchFinish
let router = DefaultRouter(navigationController: navigationController)
super.init(router: router)

logger.log("SceneCoordinator init completed (UUID: \(uuid))", level: .debug, category: .lifecycle)
window?.rootViewController = navigationController
window?.makeKeyAndVisible()
}
Expand Down
2 changes: 1 addition & 1 deletion firefox-ios/Client/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
Expand Down

1 comment on commit c0e366f

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error!

InterpreterError at template.tasks[0].extra[0].treeherder[1].symbol: unknown context value cron

Please sign in to comment.