@onekeyfe/react-native-native-overlay 6.8.0-22 → 6.8.0-23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/SPEC.md CHANGED
@@ -346,10 +346,16 @@ not change React ownership. Public APIs, Android/Web, and page scope are unchang
346
346
  non-terminal re-presentation; clear it on terminal close or invalidation.
347
347
  - Preserve existing touch-driven input activation. Removing a non-key window
348
348
  MUST NOT change the key window or a surviving first responder. Removing the
349
- key window restores the highest-ranked desired-visible, attached, non-closing eligible
350
- entry in the same scene, otherwise the app window. Eligible entries are
351
- effectively blocking (system sheets always block), or actually contain a
352
- first responder; passive toast/debug entries do not win solely by level.
349
+ key window restores the highest-ranked desired-visible, attached, non-closing
350
+ eligible entry in the same scene, then the original app window if it is
351
+ still attached to that scene. When neither target exists, preserve the key
352
+ ownership of an app or system window after release or retirement. If the
353
+ scene has no key window or UIKit gives key to an ineligible overlay, use an
354
+ available visible normal-level app window in the same scene with a root
355
+ controller and the ability to become key. This fallback also handles an
356
+ exiting overlay that remains key while it is retained for touches.
357
+ Eligible entries are effectively blocking (system sheets always block) or
358
+ contain a first responder. Passive toast/debug entries need a first responder.
353
359
  Keyboard restoration may finish after dismissal completion; callers/tests
354
360
  requiring keyboard geometry must observe the new keyboard readiness event.
355
361
  - Delivered-touch retirement extension (Implemented; thirty native checks and
@@ -364,16 +370,16 @@ not change React ownership. Public APIs, Android/Web, and page scope are unchang
364
370
  tracked touch ends or cancels, then fails and resets without recognizing.
365
371
  It accepts concurrent touch types with `requiresExclusiveTouchType = false`
366
372
  and preserves UIKit's default allowed touch types.
367
- - Removing an entry while its real app window or any active/retired entry owned
368
- by that real host has delivered active touches or
369
- an interactive UIKit presentation
370
- removes that entry from active ordering and restores key ownership immediately,
371
- but retains its exiting window/root/scene, without hiding it, until both the
372
- delivered touch set is empty and the interaction finishes or cancels. Touch
373
- completion/cancellation and UIKit interaction changes schedule cleanup on the
374
- next main turn. Cleanup rechecks the complete current touch set and transition
375
- coordinator before releasing
376
- that exact window lifetime. A newly interactive transition keeps it retired
373
+ - On removal, the manager updates active ordering and restores key ownership
374
+ immediately. It keeps the exiting window visible and retains its root
375
+ controller and scene attachment while the real app window or any active or
376
+ retired entry of that host has delivered active touches, or while the app
377
+ window has an interactive UIKit transition. The search covers the root,
378
+ presented controllers, and child controllers whose loaded views belong to
379
+ the app window. Touch completion/cancellation and UIKit interaction changes
380
+ schedule cleanup on the next main turn. Cleanup rechecks the complete current
381
+ touch set and transition coordinator before releasing that exact window
382
+ lifetime. A newly interactive transition keeps it retired
377
383
  until its own completion; repeated or late callbacks cannot release a new
378
384
  entry for the same owner. A new touch beginning after a previous touch ends but
379
385
  before queued cleanup keeps the window retired. Overlapping multi-touch can
@@ -381,10 +387,13 @@ not change React ownership. Public APIs, Android/Web, and page scope are unchang
381
387
  still releases synchronously. Remove an entry observer only when its window
382
388
  is released; remove a real app window's observer only when that host has no
383
389
  active or retired entries. Touch callbacks query current host ownership across
384
- scenes, rather than binding to the scene of first installation. Moving the
385
- same real host to another scene keeps its remaining users protected.
390
+ scenes using an identity unique to each host window lifetime. Moving the
391
+ same real host to another scene keeps its remaining users protected. The
392
+ identity holds a weak reference to the host, so a last-touch check can
393
+ release a retired window even if the host deallocates before the callback
394
+ or while the check is queued.
386
395
  Reassigning an observed window to a different host does not change its
387
- delivered touch context: retain weak prior-host associations until a next-turn
396
+ delivered touch context. Retain prior host identities until a next-turn
388
397
  check finds its complete touch set empty and those hosts' retirements released.
389
398
  A new touch during an idle gap still protects a prior host whose context remains
390
399
  retired. Touch completion, observer removal and host reassignment wake current
@@ -799,16 +808,18 @@ system multi-scene migration. The default resolver remains `ObjectIdentifier(sce
799
808
  Automated (P0):
800
809
 
801
810
  - `tests/ios/run.sh` compiles the production WindowManager, SheetController and
802
- Animation into an isolated UIKit test app. Its original nineteen checks cover bounded/live
803
- ordering, key restoration eligibility, owning-entry release, injected scene
811
+ Animation into an isolated UIKit test app. Checks cover bounded/live ordering,
812
+ key restoration eligibility, owning-entry release, injected scene
804
813
  disconnect/reuse with original-window identity and reentrant-registration
805
814
  rejection, conditional original-input focus restoration (including
806
815
  higher/foreign/new-input guards), and a native sheet surviving another
807
- entry's dismissal. Four focused checks cover interactive retirement after
816
+ entry's dismissal. Six focused checks cover interactive retirement after
808
817
  finish and cancellation, reopening the same owner while the old window is
809
- retired, and disconnecting a scene with only a retired window. They use a
810
- controlled transition coordinator to test manager lifecycle; the real
811
- gesture check is the iOS 27.0 simulator run above.
818
+ retired, and disconnecting a scene with only a retired window. Four use a
819
+ controlled transition coordinator to test manager lifecycle. One uses a
820
+ real contained `UINavigationController` interactive pop to verify retention
821
+ until cancellation. One ensures unloaded and unattached children do not
822
+ retain the window or load their views.
812
823
  Eight app-touch checks directly drive the production observer's
813
824
  `touchesBegan`/`touchesEnded`/`touchesCancelled` and reset with synthetic
814
825
  touch objects. They assert passive gesture flags, touch-only retirement,
@@ -817,6 +828,21 @@ Automated (P0):
817
828
  and scene-disconnect callback invalidation. They prove manager lifecycle,
818
829
  not UIKit delivery or scroll inertia; those are covered separately by the
819
830
  local App runtime checks above, with the stated selector-entry limitation.
831
+ The queued-cleanup fixtures explicitly model reset followed by DOWN on the
832
+ same observer. When a fixture ends a gesture with UP and later reuses the
833
+ observer, it waits for UIKit to return the recognizer to the possible state.
834
+ Host lifetime checks detach and deallocate a real UIWindow on either side of
835
+ the last touch callback. A separate check verifies UIKit key handoff to an
836
+ eligible app window while the exiting overlay is still attached for a touch.
837
+ The two-app-window check verifies that, without an eligible overlay or
838
+ attached original host, synchronous release preserves the key window UIKit
839
+ restored even when another app window is the first fallback candidate.
840
+ The closing-overlay check sets the closing overlay as key to verify the
841
+ fallback candidate independently of UIKit's release order. It then verifies
842
+ that releasing a different key overlay leaves the app window key and the
843
+ closing overlay attached. UIKit's intermediate choice is recorded with the
844
+ simulator OS version and can vary without failing the check. Synchronous
845
+ key restoration to the closing overlay was observed on iOS 18.6 and 27.0.
820
846
  Sheet checks use `animated: false`; they do not compile the React/Fabric
821
847
  Container or replace Gallery coverage of animated reversal/generation races,
822
848
  real multi-scene/disconnect, keyboard geometry or accessibility.
@@ -201,9 +201,15 @@ final class NativeOverlayAppTouchObserver: UIGestureRecognizer {
201
201
  final class NativeOverlayWindowManager: NSObject {
202
202
  static let shared = NativeOverlayWindowManager()
203
203
 
204
+ // Touches can outlive the app window that owns their routing context.
205
+ private final class AppWindowLifetime: NSObject {
206
+ weak var window: UIWindow?
207
+ init(_ window: UIWindow) { self.window = window }
208
+ }
209
+
204
210
  private final class Entry {
205
211
  weak var owner: NativeOverlayWindowOwner?
206
- weak var appWindow: UIWindow?
212
+ var host: AppWindowLifetime
207
213
  let window: NativeOverlayPassthroughWindow
208
214
  let sequence: Int
209
215
  let level: NativeOverlayLevel
@@ -212,11 +218,11 @@ final class NativeOverlayWindowManager: NSObject {
212
218
  var desiredVisible = true
213
219
  var closing = false
214
220
 
215
- init(owner: NativeOverlayWindowOwner, appWindow: UIWindow,
221
+ init(owner: NativeOverlayWindowOwner, host: AppWindowLifetime,
216
222
  window: NativeOverlayPassthroughWindow, sequence: Int,
217
223
  level: NativeOverlayLevel, stackOrder: Int, blocking: Bool) {
218
224
  self.owner = owner
219
- self.appWindow = appWindow
225
+ self.host = host
220
226
  self.window = window
221
227
  self.sequence = sequence
222
228
  self.level = level
@@ -227,39 +233,36 @@ final class NativeOverlayWindowManager: NSObject {
227
233
 
228
234
  private final class RetiredWindow {
229
235
  let window: NativeOverlayPassthroughWindow
230
- weak var appWindow: UIWindow?
236
+ let host: AppWindowLifetime
231
237
  weak var observedCoordinator: AnyObject?
232
238
 
233
- init(window: NativeOverlayPassthroughWindow, appWindow: UIWindow?) {
239
+ init(window: NativeOverlayPassthroughWindow, host: AppWindowLifetime) {
234
240
  self.window = window
235
- self.appWindow = appWindow
241
+ self.host = host
236
242
  }
237
243
  }
238
244
 
239
- private final class WeakAppWindow {
240
- weak var window: UIWindow?
241
- init(_ window: UIWindow) { self.window = window }
242
- }
243
-
244
245
  private final class AppTouchObservation {
245
246
  weak var window: UIWindow?
246
- weak var appWindow: UIWindow?
247
+ var host: AppWindowLifetime
247
248
  let observer: NativeOverlayAppTouchObserver
248
- var previousAppWindows: [ObjectIdentifier: WeakAppWindow] = [:]
249
+ var previousHosts = Set<AppWindowLifetime>()
249
250
 
250
- var appWindows: [UIWindow] {
251
- (appWindow.map { [$0] } ?? []) + previousAppWindows.values.compactMap(\.window)
251
+ var hosts: [AppWindowLifetime] {
252
+ [host] + Array(previousHosts)
252
253
  }
253
254
 
254
- init(window: UIWindow, appWindow: UIWindow, observer: NativeOverlayAppTouchObserver) {
255
+ init(window: UIWindow, host: AppWindowLifetime, observer: NativeOverlayAppTouchObserver) {
255
256
  self.window = window
256
- self.appWindow = appWindow
257
+ self.host = host
257
258
  self.observer = observer
258
259
  }
259
260
  }
260
261
 
261
262
  private var scenes: [ObjectIdentifier: [ObjectIdentifier: Entry]] = [:]
262
263
  private var retiredWindows: [ObjectIdentifier: [ObjectIdentifier: RetiredWindow]] = [:]
264
+ private let hostLifetimes = NSMapTable<UIWindow, AppWindowLifetime>(
265
+ keyOptions: [.weakMemory, .objectPointerPersonality], valueOptions: .strongMemory)
263
266
  private var appTouchObservations: [ObjectIdentifier: AppTouchObservation] = [:]
264
267
  private var disconnectingScenes = Set<ObjectIdentifier>()
265
268
  private var sequence = 0
@@ -299,7 +302,8 @@ final class NativeOverlayWindowManager: NSObject {
299
302
  guard !disconnectingScenes.contains(sceneKey) else { return nil }
300
303
  let orphanWindows = (scenes[sceneKey] ?? [:]).values.filter { $0.owner == nil }.map(\.window)
301
304
  orphanWindows.forEach { entryRemoved(from: $0) }
302
- observeTouches(in: appWindow, appWindow: appWindow)
305
+ let host = hostLifetime(for: appWindow)
306
+ observeTouches(in: appWindow, host: host)
303
307
  let ownerKey = ObjectIdentifier(owner)
304
308
  var entries = scenes[sceneKey] ?? [:]
305
309
  let entry: Entry
@@ -315,14 +319,14 @@ final class NativeOverlayWindowManager: NSObject {
315
319
  root.appWindow = appWindow
316
320
  window.rootViewController = root
317
321
  window.frame = scene.coordinateSpace.bounds
318
- entry = Entry(owner: owner, appWindow: appWindow, window: window,
322
+ entry = Entry(owner: owner, host: host, window: window,
319
323
  sequence: sequence, level: level, stackOrder: stackOrder, blocking: blocking)
320
324
  entries[ownerKey] = entry
321
325
  scenes[sceneKey] = entries
322
326
  }
323
- entry.appWindow = appWindow
327
+ entry.host = host
324
328
  (entry.window.rootViewController as? NativeOverlayRootViewController)?.appWindow = appWindow
325
- observeTouches(in: entry.window, appWindow: appWindow)
329
+ observeTouches(in: entry.window, host: host)
326
330
  reorder(entries)
327
331
  entry.window.isHidden = false
328
332
  entry.window.rootViewController?.setNeedsStatusBarAppearanceUpdate()
@@ -356,11 +360,10 @@ final class NativeOverlayWindowManager: NSObject {
356
360
  let wasKey = entry.window.isKeyWindow
357
361
  let scene = entry.window.windowScene
358
362
  scenes[sceneKey]?[ownerKey] = nil
359
- let remaining = scenes[sceneKey] ?? [:]
360
- if remaining.isEmpty { scenes[sceneKey] = nil }
361
- if hasActiveTouches(in: entry.appWindow) || Self.interactiveCoordinator(in: entry.appWindow) != nil {
363
+ if scenes[sceneKey]?.isEmpty == true { scenes[sceneKey] = nil }
364
+ if hasActiveTouches(for: entry.host) || Self.interactiveCoordinator(in: entry.host.window) != nil {
362
365
  // Keep the routing context until this host's delivered touches and UIKit interactions finish.
363
- let retirement = RetiredWindow(window: entry.window, appWindow: entry.appWindow)
366
+ let retirement = RetiredWindow(window: entry.window, host: entry.host)
364
367
  let windowKey = ObjectIdentifier(entry.window)
365
368
  retiredWindows[sceneKey, default: [:]][windowKey] = retirement
366
369
  finishRetirement(retirement, sceneKey: sceneKey, windowKey: windowKey)
@@ -368,13 +371,19 @@ final class NativeOverlayWindowManager: NSObject {
368
371
  release(entry.window)
369
372
  }
370
373
  removeUnusedTouchObservers()
374
+ let remaining = scenes[sceneKey] ?? [:]
371
375
  reorder(remaining)
372
376
  guard wasKey, let scene,
373
377
  scene.activationState == .foregroundActive || scene.activationState == .foregroundInactive else { return }
374
378
  let next = remaining.values.filter { Self.eligible($0, in: scene) }
375
379
  .max { Self.ordered($0, before: $1) }
376
- let appWindow = entry.appWindow?.windowScene === scene ? entry.appWindow : nil
377
- (next?.window ?? appWindow)?.makeKey()
380
+ let appWindow = entry.host.window
381
+ let attachedAppWindow = appWindow?.windowScene === scene ? appWindow : nil
382
+ if let target = next?.window ?? attachedAppWindow {
383
+ target.makeKey()
384
+ return
385
+ }
386
+ Self.fallbackKeyWindow(in: scene)?.makeKey()
378
387
  }
379
388
 
380
389
  func restoreFocus(_ responder: UIView, in window: UIWindow) -> Bool {
@@ -386,7 +395,7 @@ final class NativeOverlayWindowManager: NSObject {
386
395
  guard entries.values.filter({ Self.eligible($0, in: scene) })
387
396
  .max(by: { Self.ordered($0, before: $1) }) === entry,
388
397
  let key = scene.windows.first(where: { $0.isKeyWindow }) else { return false }
389
- if key !== entry.appWindow {
398
+ if key !== entry.host.window {
390
399
  guard let keyEntry = entries.values.first(where: { $0.window === key && $0.owner != nil }),
391
400
  !Self.ordered(entry, before: keyEntry) else { return false }
392
401
  }
@@ -401,6 +410,16 @@ final class NativeOverlayWindowManager: NSObject {
401
410
  (entry.blocking || firstResponder(in: entry.window) != nil)
402
411
  }
403
412
 
413
+ // The caller has already considered eligible overlays and the original host.
414
+ static func fallbackKeyWindow(in scene: UIWindowScene) -> UIWindow? {
415
+ if let keyWindow = scene.keyWindow, !(keyWindow is NativeOverlayPassthroughWindow) { return nil }
416
+ return scene.windows.first {
417
+ $0.windowScene === scene && $0.windowLevel == .normal &&
418
+ !$0.isHidden && $0.alpha > 0 && $0.rootViewController != nil &&
419
+ $0.canBecomeKey && !($0 is NativeOverlayPassthroughWindow)
420
+ }
421
+ }
422
+
404
423
  private func find(_ window: UIWindow?) -> (ObjectIdentifier, ObjectIdentifier, Entry)? {
405
424
  guard let window else { return nil }
406
425
  for (sceneKey, entries) in scenes {
@@ -443,99 +462,105 @@ final class NativeOverlayWindowManager: NSObject {
443
462
  window.windowScene = nil
444
463
  }
445
464
 
446
- private func observeTouches(in window: UIWindow, appWindow: UIWindow) {
465
+ private func hostLifetime(for window: UIWindow) -> AppWindowLifetime {
466
+ if let host = hostLifetimes.object(forKey: window) { return host }
467
+ let host = AppWindowLifetime(window)
468
+ hostLifetimes.setObject(host, forKey: window)
469
+ return host
470
+ }
471
+
472
+ private func observeTouches(in window: UIWindow, host: AppWindowLifetime) {
447
473
  let windowKey = ObjectIdentifier(window)
448
- if let observation = appTouchObservations[windowKey] {
449
- if observation.appWindow !== appWindow, let previous = observation.appWindow {
450
- // Reparenting does not change the context of an already delivered or queued touch stream.
451
- if observation.observer.hasActiveTouches || hasRetirements(for: previous) {
452
- observation.previousAppWindows[ObjectIdentifier(previous)] = WeakAppWindow(previous)
453
- }
454
- observation.appWindow = appWindow
455
- scheduleObservationCleanup(observation, windowKey: windowKey)
456
- scheduleRetirementCheck(for: previous)
457
- } else {
458
- observation.appWindow = appWindow
474
+ if let observation = appTouchObservations[windowKey], observation.window === window {
475
+ let previous = observation.host
476
+ guard previous !== host else { return }
477
+ // Reparenting does not change the context of an already delivered or queued touch stream.
478
+ if observation.observer.hasActiveTouches || hasRetirements(for: previous) {
479
+ observation.previousHosts.insert(previous)
459
480
  }
481
+ observation.host = host
482
+ observation.previousHosts.remove(host)
483
+ scheduleObservationCleanup(observation, windowKey: windowKey)
484
+ scheduleRetirementCheck(for: previous)
460
485
  return
461
486
  }
462
487
  let observer = NativeOverlayAppTouchObserver(target: nil, action: nil)
463
- appTouchObservations[windowKey] = AppTouchObservation(
464
- window: window, appWindow: appWindow, observer: observer)
465
- observer.onTouchesFinished = { [weak self, weak window, weak observer] in
466
- guard let self, let window, let observer,
467
- let observation = self.appTouchObservations[ObjectIdentifier(window)],
488
+ appTouchObservations[windowKey] = AppTouchObservation(window: window, host: host, observer: observer)
489
+ observer.onTouchesFinished = { [weak self, weak observer] in
490
+ guard let self, let observer,
491
+ let observation = self.appTouchObservations[windowKey],
468
492
  observation.observer === observer else { return }
469
- self.scheduleObservationCleanup(observation, windowKey: ObjectIdentifier(window))
470
- for appWindow in observation.appWindows { self.scheduleRetirementCheck(for: appWindow) }
493
+ self.scheduleObservationCleanup(observation, windowKey: windowKey)
494
+ for host in observation.hosts { self.scheduleRetirementCheck(for: host) }
471
495
  }
472
496
  window.addGestureRecognizer(observer)
473
497
  }
474
498
 
475
499
  private func scheduleObservationCleanup(_ observation: AppTouchObservation, windowKey: ObjectIdentifier) {
476
- guard !observation.previousAppWindows.isEmpty else { return }
500
+ guard !observation.previousHosts.isEmpty else { return }
477
501
  DispatchQueue.main.async { [weak self, weak observation] in
478
502
  guard let self, let observation, self.appTouchObservations[windowKey] === observation,
479
503
  !observation.observer.hasActiveTouches else { return }
480
- self.prunePreviousAppWindows(in: observation)
504
+ self.prunePreviousHosts(in: observation)
481
505
  }
482
506
  }
483
507
 
484
- private func prunePreviousAppWindows(in observation: AppTouchObservation) {
508
+ private func prunePreviousHosts(in observation: AppTouchObservation) {
485
509
  guard !observation.observer.hasActiveTouches else { return }
486
510
  // An idle gap does not retire the old context if another touch or transition still owns it.
487
- observation.previousAppWindows = observation.previousAppWindows.filter {
488
- $0.value.window.map { hasRetirements(for: $0) } ?? false
489
- }
511
+ observation.previousHosts = observation.previousHosts.filter { hasRetirements(for: $0) }
490
512
  }
491
513
 
492
- private func hasRetirements(for appWindow: UIWindow) -> Bool {
493
- retiredWindows.values.contains { $0.values.contains { $0.appWindow === appWindow } }
514
+ private func hasRetirements(for host: AppWindowLifetime) -> Bool {
515
+ retiredWindows.values.contains { $0.values.contains { $0.host === host } }
494
516
  }
495
517
 
496
- private func scheduleRetirementCheck(for appWindow: UIWindow?) {
497
- guard let appWindow, hasRetirements(for: appWindow) else { return }
498
- DispatchQueue.main.async { [weak self, weak appWindow] in
499
- guard let self, let appWindow else { return }
518
+ private func scheduleRetirementCheck(for host: AppWindowLifetime) {
519
+ guard hasRetirements(for: host) else { return }
520
+ DispatchQueue.main.async { [weak self] in
521
+ guard let self else { return }
500
522
  // The source observer may be gone; query current host ownership and all delivered touches.
501
523
  for (sceneKey, windows) in self.retiredWindows {
502
- for (windowKey, retirement) in windows where retirement.appWindow === appWindow {
524
+ for (windowKey, retirement) in windows where retirement.host === host {
503
525
  self.finishRetirement(retirement, sceneKey: sceneKey, windowKey: windowKey)
504
526
  }
505
527
  }
506
528
  }
507
529
  }
508
530
 
509
- private func hasActiveTouches(in appWindow: UIWindow?) -> Bool {
510
- guard let appWindow else { return false }
511
- return appTouchObservations.values.contains {
512
- $0.observer.hasActiveTouches && ($0.appWindow === appWindow ||
513
- $0.previousAppWindows[ObjectIdentifier(appWindow)]?.window === appWindow)
531
+ private func hasActiveTouches(for host: AppWindowLifetime) -> Bool {
532
+ appTouchObservations.values.contains {
533
+ $0.window != nil && $0.observer.hasActiveTouches &&
534
+ ($0.host === host || $0.previousHosts.contains(host))
514
535
  }
515
536
  }
516
537
 
517
538
  private func removeUnusedTouchObservers() {
518
539
  for (key, observation) in appTouchObservations {
519
- prunePreviousAppWindows(in: observation)
540
+ prunePreviousHosts(in: observation)
520
541
  let active = observation.window.map { window in
521
- scenes.values.contains { $0.values.contains { $0.window === window || $0.appWindow === window } } ||
522
- retiredWindows.values.contains { $0.values.contains { $0.window === window || $0.appWindow === window } }
542
+ scenes.values.contains { $0.values.contains { $0.window === window || $0.host.window === window } } ||
543
+ retiredWindows.values.contains { $0.values.contains { $0.window === window || $0.host.window === window } }
523
544
  } ?? false
524
545
  guard !active else { continue }
525
546
  observation.observer.onTouchesFinished = nil
526
547
  observation.window?.removeGestureRecognizer(observation.observer)
527
548
  appTouchObservations[key] = nil
528
- for appWindow in observation.appWindows { scheduleRetirementCheck(for: appWindow) }
549
+ for host in observation.hosts { scheduleRetirementCheck(for: host) }
529
550
  }
530
551
  }
531
552
 
532
553
  private static func interactiveCoordinator(in appWindow: UIWindow?) -> UIViewControllerTransitionCoordinator? {
533
- var controller = appWindow?.rootViewController
534
- while let current = controller {
554
+ guard let appWindow, let root = appWindow.rootViewController else { return nil }
555
+ var stack = [root]
556
+ var visited = Set<ObjectIdentifier>()
557
+ while let current = stack.popLast() {
558
+ guard visited.insert(ObjectIdentifier(current)).inserted else { continue }
535
559
  if let coordinator = current.transitionCoordinator, coordinator.isInteractive {
536
560
  return coordinator
537
561
  }
538
- controller = current.presentedViewController
562
+ stack.append(contentsOf: current.children.filter { $0.viewIfLoaded?.window === appWindow })
563
+ if let presented = current.presentedViewController { stack.append(presented) }
539
564
  }
540
565
  return nil
541
566
  }
@@ -543,8 +568,8 @@ final class NativeOverlayWindowManager: NSObject {
543
568
  private func finishRetirement(_ retirement: RetiredWindow, sceneKey: ObjectIdentifier,
544
569
  windowKey: ObjectIdentifier) {
545
570
  guard retiredWindows[sceneKey]?[windowKey] === retirement else { return }
546
- let coordinator = Self.interactiveCoordinator(in: retirement.appWindow)
547
- if coordinator == nil && !hasActiveTouches(in: retirement.appWindow) {
571
+ let coordinator = Self.interactiveCoordinator(in: retirement.host.window)
572
+ if coordinator == nil && !hasActiveTouches(for: retirement.host) {
548
573
  retiredWindows[sceneKey]?[windowKey] = nil
549
574
  if retiredWindows[sceneKey]?.isEmpty == true { retiredWindows[sceneKey] = nil }
550
575
  release(retirement.window)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-native-overlay",
3
- "version": "6.8.0-22",
3
+ "version": "6.8.0-23",
4
4
  "description": "Native and Web overlay hosts with ordered levels, page scope and Fabric measurement",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",