Skip to content

Lockdown Mode sheet is lost when the editor is already presenting #664

Description

@jkmassel

LockdownModeMonitor.presentSheetIfNeeded consumes its one-shot flags before it attempts the presentation, so a presentation that fails silently costs the user the warning for the rest of that editor session.

Detail

ios/Sources/GutenbergKit/Sources/Services/LockdownModeMonitor.swift:148-150 sets hasShownSheet = true and shouldShowSheet = false, and only then calls presentingViewController.present(hostingController, animated: true) at :176. Nothing re-checks whether the presentation actually happened — present(_:animated:) is a no-op when the presenter is already presenting something.

Recovery is closed off too. handleWillEnterForeground early-returns at :119 on guard newValue != self.isLockdownModeEnabled, so while Lockdown Mode stays enabled the value never changes and resetForForegroundCheck() (:95) is unreachable. detectLockdownMode only re-arms shouldShowSheet on a disabled → enabled transition with !hasShownSheet (:79-80).

How it bites

The editor finishes loading while it is already presenting something — a sheet the user opened, or a host-presented modal. didLoadEditor() (EditorViewController.swift:889) calls presentSheetIfNeeded at :908, the flags are consumed, the present silently does nothing, and the Lockdown Mode user never sees the explanation for why the editor may misbehave.

Scoped to that editor instance — lockdownModeMonitor is constructed per editor (EditorViewController.swift:229), so the next editor gets a fresh monitor. Not permanent, but the warning is lost for the session it mattered in.

Suggested fix

Set the flags after a confirmed presentation, or guard on presentingViewController.presentedViewController == nil before consuming them.

Found while reviewing #651. Pre-existing; not introduced there.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Type] BugAn existing feature does not function as intendediOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions