Skip to content

Commit 59ec1a1

Browse files
authored
fix(snapshot): stop iOS 27 floating-bar containers from covering content (callstack#3912)
* fix(snapshot): stop iOS 27 floating-bar containers from covering content On iOS 27 a `_UIFloatingBarContainerView` (type `Toolbar`) marks content covered in two shapes the sibling-sized and full-viewport exemptions miss. A tabbar/toolbar/navigationbar container whose rect matches its parent is exempt when a sibling branch encloses it. The runner prunes the same-size sibling the raw tree lists, so the container ends up beside the larger content branch instead. The full-viewport check accepts a container that matches the viewport's x, width and bottom edge and starts up to 4pt below its top. An app that draws a 2pt strip above its window content pushes the container to y=2. Fixes callstack#3883 * fix(snapshot): drop the parent-sized chrome rule, keep the top-inset footprint The regular iOS projection collapses duplicate identities and presents the floating-bar containers as application-level siblings, so a container never matches its presented parent. A live iPhone 18 Pro Max iOS 27.0 capture shows both containers under the application: the y=64 pair exempt each other and the y=2 container needs only the top-inset footprint. The parent-sized rule, its three tests, and the pruning claim in its comment go; the raw tree the issue carries is the raw projection, which the daemon never annotates.
1 parent 87f68d2 commit 59ec1a1

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

‎packages/capture-kit/src/snapshot-occlusion.test.ts‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,50 @@ test('a full-viewport toolbar container does not cover its application siblings'
671671
assert.equal(annotated[1]?.interactionBlocked, undefined);
672672
});
673673

674+
test.for([
675+
// #3883: on iOS 27 an app's 2pt top bar pushes the floating-bar container to y=2.
676+
{
677+
name: 'a toolbar container 2pt below the viewport top does not cover its application siblings',
678+
topInset: 2,
679+
expected: undefined,
680+
},
681+
{
682+
name: 'a toolbar container 4pt below the viewport top does not cover its application siblings',
683+
topInset: 4,
684+
expected: undefined,
685+
},
686+
{
687+
name: 'a toolbar container 5pt below the viewport top covers its application siblings',
688+
topInset: 5,
689+
expected: 'covered',
690+
},
691+
])('$name', ({ topInset, expected }) => {
692+
const application: RawSnapshotNode = {
693+
index: 0,
694+
type: 'application',
695+
rect: { x: 0, y: 0, width: 440, height: 956 },
696+
};
697+
const target: RawSnapshotNode = {
698+
index: 1,
699+
type: 'button',
700+
role: 'button',
701+
parentIndex: 0,
702+
label: 'Room',
703+
rect: { x: 16, y: 313, width: 408, height: 46 },
704+
};
705+
const toolbarContainer: RawSnapshotNode = {
706+
index: 2,
707+
type: 'toolbar',
708+
parentIndex: 0,
709+
label: 'Toolbar',
710+
rect: { x: 0, y: topInset, width: 440, height: 956 - topInset },
711+
};
712+
713+
const annotated = annotateCoveredSnapshotNodes([application, target, toolbarContainer]);
714+
715+
assert.equal(annotated[1]?.interactionBlocked, expected);
716+
});
717+
674718
test('the kind fields join with a separator, so adjacent fragments never accidentally concatenate into a match', () => {
675719
// type "tab" + role "bar" must read as "tab bar" (no match for the
676720
// 'tabbar' overlay fragment) — never "tabbar" via an unseparated join,

‎packages/capture-kit/src/snapshot-occlusion.ts‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ const OVERLAY_KIND_FRAGMENTS = [
2626
'menu',
2727
];
2828
const VIEWPORT_CHROME_KIND_FRAGMENTS = ['tabbar', 'toolbar', 'navigationbar'];
29+
/**
30+
* How far below the viewport top a full-viewport chrome container may start, before the 0.5pt rect
31+
* tolerance. On iOS 27 an app that draws a 2pt bar at the top gets a `_UIFloatingBarContainerView`
32+
* at y=2 (#3883). A container that starts below the status bar is tens of points down and gets no
33+
* exemption from this check.
34+
*/
35+
const VIEWPORT_CHROME_TOP_INSET_PT = 4;
2936
const TOOLBAR_HOST_KIND_FRAGMENTS = ['toolbar'];
3037
const SCROLL_INDICATOR_KIND_FRAGMENTS = ['scrollbar', 'scrollindicator'];
3138
const SEMANTIC_TOUCH_KIND_FRAGMENTS = [
@@ -421,7 +428,7 @@ function isFullViewportChromeContainer(
421428
while (current && !visited.has(current.index)) {
422429
if (isViewportRootNode(current)) {
423430
const viewportRect = positiveRect(current.rect);
424-
return Boolean(viewportRect && areRectsApproximatelyEqual(rect, viewportRect));
431+
return Boolean(viewportRect && isViewportFootprint(rect, viewportRect));
425432
}
426433
visited.add(current.index);
427434
current =
@@ -531,3 +538,13 @@ function positiveRect(rect: RawSnapshotNode['rect']): Rect | null {
531538
function mergeCoveredHint(hints: string[] | undefined): string[] {
532539
return Array.from(new Set([...(hints ?? []), COVERED_PRESENTATION_HINT]));
533540
}
541+
542+
/** The viewport's frame, or the viewport below a strip of at most `VIEWPORT_CHROME_TOP_INSET_PT`. */
543+
function isViewportFootprint(rect: Rect, viewport: Rect): boolean {
544+
const topInset = Math.min(Math.max(rect.y - viewport.y, 0), VIEWPORT_CHROME_TOP_INSET_PT);
545+
return areRectsApproximatelyEqual(rect, {
546+
...viewport,
547+
y: viewport.y + topInset,
548+
height: viewport.height - topInset,
549+
});
550+
}

0 commit comments

Comments
 (0)