Skip to content

Defer the notice presenter's window until the first presentation#25637

Open
crazytonyli wants to merge 3 commits into
trunkfrom
task/scene-api-notice-presenter
Open

Defer the notice presenter's window until the first presentation#25637
crazytonyli wants to merge 3 commits into
trunkfrom
task/scene-api-notice-presenter

Conversation

@crazytonyli

@crazytonyli crazytonyli commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Note

I recommend reviewing this PR commit by commit. The first commit is swift-format only.

Description

Second PR in the UIScene life cycle preparation series, after #25636.

NoticePresenter created its UntouchableWindow eagerly at setup via init(frame:), which leaves the window without a windowScene; such a window silently never displays once the app adopts the scene life cycle.

  1. The window is now created on the first foreground presentation, attached to the active scene, and reattached if the scene has changed since creation.
  2. A notice posted before any scene is connected (e.g. during launch) stays at the head of the queue and presentation is retried when the app becomes active, instead of being dropped.
  3. Since the window can no longer be assumed to exist, the fatalError-backed view accessor is removed; presentation reads the view from the window it just ensured, and the keyboard and dismissal paths reach it through the container's superview.

Testing instructions

Regression-test notices: trigger a few (e.g. save a draft, publish a post), and check a notice posted right before backgrounding is delivered as a local notification.

@dangermattic

dangermattic commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot

wpmobilebot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number32566
VersionPR #25637
Bundle IDorg.wordpress.alpha
Commita6a1f30
Installation URL7trav2ipijt2o
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number32566
VersionPR #25637
Bundle IDcom.jetpack.alpha
Commita6a1f30
Installation URL3ut4o3n7opk9o
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Base automatically changed from task/scene-api-aux-windows to trunk June 11, 2026 23:13
@crazytonyli crazytonyli force-pushed the task/scene-api-notice-presenter branch from 0bc2261 to 0816ee3 Compare June 11, 2026 23:13
@crazytonyli crazytonyli force-pushed the task/scene-api-notice-presenter branch from 0816ee3 to 4897d5a Compare June 11, 2026 23:22
UntouchableWindow was created eagerly at setup via init(frame:), which leaves
it without a windowScene; such a window does not display (or attaches to the
wrong scene) under the UIScene life cycle. The window is now created on the
first foreground presentation, attached to the active scene, reattaching it
if the scene has changed since the window was created. When no scene is
connected yet (e.g. a notice posted during launch, before UIKit connects the
scene), the notice stays at the head of the queue and presentation is retried
once the app becomes active. The presenter also processes any notice posted
before it was created, since the store does not replay state to new
subscribers. The frame-based initializer is replaced with a windowScene one.
@crazytonyli crazytonyli force-pushed the task/scene-api-notice-presenter branch from 4897d5a to a49a457 Compare June 12, 2026 00:57
The presenter's view accessor required the lazily created window to exist,
backed by a fatalError; its safety depended on guards scattered across the
call sites. Presentation now reads the view from the window it just ensured,
and the keyboard and dismissal paths reach it through the container's
superview, so the accessor and its fatalError are gone.
@crazytonyli crazytonyli requested a review from jkmassel June 12, 2026 01:19
@crazytonyli crazytonyli added this to the 27.0 milestone Jun 12, 2026
@crazytonyli crazytonyli marked this pull request as ready for review June 12, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants