Repository navigation
perf(app): stop holding semantics on for rage-click context on iOS - #23400
Conversation
RageClickContextTracker held SemanticsBinding.ensureSemantics() for the app's lifetime on iOS builds with PostHog, so every production iOS frame also compiled the semantics tree: 17-25% of UI-thread pipeline time while scrolling a row-heavy list (test/perf/rage_click_semantics_cost_test.dart). Host harnesses never mounted the tracker, so they never saw it. Resolve the tapped control and route title from the render objects under the pointer instead (one hit test per pointer down). Labels still come only from identifiers, explicit labels, buttons/links and tooltips; a plain tap target reports tap_target, never its content. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fbae11ce73
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (node is SemanticsAnnotationsMixin && node.properties.namesRoute == true) { | ||
| found = _normalize(node.properties.label ?? '') ?? _textBelow(node); |
There was a problem hiding this comment.
Resolve route names on the platform that mounts the tracker
On iOS, where this tracker is mounted, Flutter 3.44.5's AppBar sets namesRoute to null; it is true only on Android, Fuchsia, Linux, and Windows. Consequently this condition never recognizes a normal iOS app-bar title, so screenName is null and setInteractionContext leaves the previous screen super-property in place. The new test passes only because it uses the host's default platform despite describing production iOS; exercise it with TargetPlatform.iOS and use the iOS header/title annotation as a fallback.
Useful? React with 👍 / 👎.
| for (final node in path) { | ||
| if (node is! SemanticsAnnotationsMixin) continue; | ||
| final p = node.properties; | ||
| final identifier = _normalize(p.identifier ?? ''); | ||
| if (identifier != null) return identifier; | ||
|
|
||
| if (!node.rect.contains(localPosition) || node.flagsCollection.isHidden) return null; | ||
| final interactive = p.button == true || p.link == true || p.textField == true || p.onTap != null; | ||
| final label = _normalize(p.label ?? ''); | ||
| if (label != null && interactive) return label; |
There was a problem hiding this comment.
Honor replacement semantics before inspecting descendants
When an outer Semantics(excludeSemantics: true, ...) intentionally replaces its child's semantics, this deepest-first scan can return an inner control before reaching that replacement annotation. For example, OmiDateFilterChip replaces its child OmiButton with the label Remove filter, …, but the inner TextButton is encountered first and _textBelow reports the visual … × label instead. Respect SemanticsAnnotationsMixin.excludeSemantics by discarding deeper candidates at that boundary so rage-click targets match the effective semantics tree.
Useful? React with 👍 / 👎.
| for (final node in path) { | ||
| if (node is SemanticsAnnotationsMixin) { | ||
| final p = node.properties; | ||
| if (p.button == true) return 'button'; | ||
| if (p.link == true) return 'link'; | ||
| if (p.textField == true) return 'text_field'; | ||
| if (p.slider == true) return 'slider'; | ||
| if (p.onTap != null) return 'tap_target'; | ||
| } | ||
| if (node is RenderSemanticsGestureHandler && node.onTap != null) return 'tap_target'; | ||
| if (node is RenderEditable) return 'text_field'; |
There was a problem hiding this comment.
Read semantics from custom control render objects
Controls that implement semantics directly in describeSemanticsConfiguration are invisible to these type checks. Flutter's material Slider, used in the goals, device-control, and notification-settings screens, is handled by its own render object rather than SemanticsAnnotationsMixin or RenderSemanticsGestureHandler; therefore tapping or dragging any of those sliders now records unlabeled_surface, whereas the previous semantics-tree implementation returned the slider fallback. Inspect each hit render object's semantics configuration, or otherwise recognize these direct-semantics controls.
Useful? React with 👍 / 👎.
|
@Git-on-my-level heads up from Nik: iOS 1.0.574 (build 1458) is in App Store review and has everything (onboarding, stay offer, your lag fix). Please do not withdraw or replace it. Three withdrawals last night each restarted Apple's queue, which is why nothing shipped. A guard now resubmits 1.0.574 if it gets pulled, and #23444 makes the promote script refuse while a version is in review. Newer builds wait for the next train after 1.0.574 is released. |
Problem
On every production iOS build with a PostHog key,
RageClickContextTracker(mounted app-wide inmain.dart) calledSemanticsBinding.instance.ensureSemantics()at startup and held it for the app's lifetime. So every frame also compiled the semantics (accessibility) tree, even with VoiceOver off. David reports scroll and tap lag on iPhone that our harnesses never reproduced, because:testWidgetsturns semantics on by default in both arms.Measurement
app/test/perf/rage_click_semantics_cost_test.dartscrolls a 400-row list for 240 drags with semantics off versus held on. The SEMANTICS phase is 17–25% of UI-thread pipeline time with semantics on (runs: 24.7%, 19.3%, 16.9%; re-run here: 19.6%, 16.6%), against 0 ms off.Change
The tracker no longer holds a
SemanticsHandle. On each pointer down it does one hit test and reads the semantics annotations already present on the render objects under the pointer:namesRoute;A plain tap target still reports
tap_target, never its content. PostHog rage clicks keep their screen and control context.Tests
test/widgets/rage_click_context_tracker_test.dart: the existing context tests, plus a guard that the tracker leaves semantics off.test/perf/rage_click_semantics_cost_test.dart: the cost probe.flutter analyzeis clean.UI-Evidence: none -- no visual change.
Release
This goes into iOS 1.0.574, to replace 1.0.573 in App Store review, per David's 10-23 approval if the cost was confirmed. Measured by the perf hill-climb lane (Opus); the same commit also sits on lane/perf-hillclimb.
Product invariants affected
INV-PERF-1: per-frame work must not scale with app-wide state when nothing relevant changed. This removes an app-lifetime per-frame semantics compile on iOS.
Failure-Class: none
🤖 Generated with Claude Code