Skip to content

Crash when shouldDisplayAboveKeyboardWindow is enabled in non-scene-based apps #37

Description

@p-x9

Description

When using TouchTracker in an app that does not adopt the scene-based lifecycle (i.e., uses the traditional UIApplicationDelegate with a single UIWindow instead of UISceneDelegate / UIWindowScene), enabling shouldDisplayAboveKeyboardWindow causes a crash.

Crash Location

The crash occurs in the following method:

keyboardScene(for screen: UIScreen)

Root Cause

In apps without scene-based lifecycle support, there is no UIWindowScene available. The keyboardScene(for:) method appears to assume that a scene-based lifecycle is in use, and likely accesses scene-related APIs that are unavailable or return nil in non-scene-based apps, leading to a crash.

Steps to Reproduce

  1. Create an iOS app that uses the traditional AppDelegate-based lifecycle (no UIScene support — no scene delegate, no scene manifest in Info.plist).
  2. Add TouchTracker via SPM.
  3. Set up TouchTrackingUIView on the app's UIWindow.
  4. Enable shouldDisplayAboveKeyboardWindow.
  5. Trigger the keyboard (e.g., tap a UITextField).
  6. Crash in keyboardScene(for:).

Expected Behavior

TouchTracker should gracefully handle the case where the app does not use a scene-based lifecycle. If the keyboard window scene is not available, it should fall back to a safe default (e.g., skip the above-keyboard display or use the app's main window instead).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions