Skip to content

Measure and report embedded content height on iOS - #776

Merged
oristanovic merged 3 commits into
mainfrom
feat/embedded-self-sizing
Oct 16, 2026
Merged

oristanovic merged 3 commits into
mainfrom
feat/embedded-self-sizing

Conversation

@oristanovic

@oristanovic oristanovic commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What do these changes do?

Measure the embedded content on iOS and report its height through
onSizeChange. A GeometryReader behind the view reports on every layout
pass, and the wrapper forwards changes once they clear a small dead band.

This also changes how the view describes its parent to the SDK. Previously an
unsized view passed screen bounds; it now passes nil, which is the SDK's own
signal for "no parent stated" and makes it resolve percentage content against
the real proposal instead.

Why are these changes necessary?

Nothing on iOS ever measured the rendered scene, so an app had no way to find
out how tall the content wanted to be.

How did you verify these changes?

Ran the example app on a simulator against a Scene that renders at its natural
height. The view sizes itself to the content, and dismissing the content
collapses it rather than leaving a gap behind.

🤖 Generated with Claude Code

Wires the sizeToContent spec to a real measurement on iOS. A GeometryReader
behind the embedded view reports its height on every layout pass, and the
wrapper forwards changes to onSizeChange after a dead band.

Three things worth a reviewer's attention:

- Height comes from a background GeometryReader rather than a SwiftUI
  preference. A preference misses the placeholder-to-content transition,
  which is exactly the case that has to reset a stale height.

- parentWidth/parentHeight now return nil when the host has not sized the
  view, instead of substituting screen bounds. Nil is the SDK's signal for
  "no parent stated", so it resolves percentages against the real proposal.
  While self sizing, parentHeight falls back to the window height: it must
  not depend on the box the host just set, or measurement and layout feed
  each other.

- Unavailability is signalled from a zero-sized placeholder rather than
  from a measured zero, which is ambiguous mid-layout.

Verified on a simulator: content self-sizes, and dismissing it collapses
the view instead of leaving a stale gap.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@oristanovic
oristanovic requested a review from a team as a code owner October 13, 2026 12:40
Comment thread ios/AirshipEmbeddedViewWrapper.swift
Base automatically changed from feat/embedded-size-spec to main October 15, 2026 07:59
Ognjen Ristanovic and others added 2 commits October 15, 2026 10:01
The measurement runs on every layout pass, so a fixed-size view was emitting
onSizeChange too. The spec documents the event as emitted only while sizing to
content, and Android only listens then.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…zing

# Conflicts:
#	ios/AirshipEmbeddedViewWrapper.swift
@oristanovic
oristanovic merged commit dcea057 into main Oct 16, 2026
1 check passed
@oristanovic
oristanovic deleted the feat/embedded-self-sizing branch October 16, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants