Skip to content

Live Activity: keep every picture to what its surface and its node can draw - #8

Merged
ayushflow merged 6 commits into
mainfrom
ayush/live-activity-image-size
Nov 30, 2026
Merged

ayushflow merged 6 commits into
mainfrom
ayush/live-activity-image-size

Conversation

@ayushflow

@ayushflow ayushflow commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Live Activity: keep every picture to what its surface and its node can draw

Problem

A Custom card's picture could show as an empty grey box. iOS archives each Live Activity surface's view and puts a grey placeholder in place of any picture that is, on either side, 1.2 times that surface's size or more, measured in pixels. Each surface has its own limit. The widget extension logs:

[com.apple.chrono:archiving] [2: 900x600] Max size exceeded: 1346.400000x576.000000; using placeholder image
[com.apple.chrono:archiving] [12: 720x480] Max size exceeded: 457.500000x220.000000; using placeholder image

FFAssetImage only capped the longest side at 900 px, so a 900x600 asset (600 px tall) was refused on the Lock Screen. The island surfaces are much smaller, so the compact and minimal island refused pictures that the Lock Screen draws. The picture the app stores for an Image value was drawn as stored, so it could hit the same limits.

Change

  • flutterflow_native_layout:
    • New ffDrawable(_:_:) helper. Before a picture is drawn, it is shrunk to the bound of the surface it is on and, when the node has a fixed size, to just what covers that size at the screen's displayScale (a 24-point node needs 72 px at 3x). With both sides fixed, the larger side ratio is used. With one fixed side, only a contained (.fit) picture is bounded by it: a cover or stretched picture fills the free side and may be drawn larger.
    • The bound is the ffPictureBound environment value (FFPictureBound). nativeLayoutSwiftBuildingBlocks takes a pictures: bound (SwiftPictureBound) as its default. A host whose surfaces differ sets it on each surface's view (SwiftPictureBound.swift). The default, kSwiftHomeWidgetPictureBound, is the current 900 px longest side, so home screen widgets keep that bound. Their fixed-size image nodes are now also shrunk to their frame (a 40-point node gets 120 px at 3x); images without a fixed size are drawn as before.
    • The emitter passes an image node's fixed width:/height: (points) to FFAssetImage and FFValueImage.
    • FFAssetImage caches by path, scale, bound and frame. FFValueImage caches its shrunk picture by the picture's identity, scale, bound and frame (at most 16 entries). An entry keeps a weak reference to its source and is used only for that same picture, so a new picture that reuses a freed one's address never gets the old result.
  • flutterflow_live_activity: each Custom card surface's view sets its own bound (kLiveActivityPictureBounds): 343 x 160 points on the Lock Screen and the expanded island, 108 x 52 on each compact side, 48 x 52 on the minimal island. kLiveActivityPictureBound (343 x 160) is the default.
  • Fixed the comment on kLiveActivityImageMaxPixels, which said the limit was about a megapixel. Stored pictures are now shrunk again when drawn.
  • The card icon (FFIconLoader) already makes a 120-point thumbnail. It is only used where no layout is designed, so it is unchanged.

Measured (iPhone 17 Pro simulator, iOS 26.5, 3x)

Each surface's limit, logged with the shrinking turned off and a distinct oversized picture on each surface:

Surface Limit (px, 3x) Limit (pt) Bound (pt) Bound at 3x (px) With this change
Lock Screen 1346.4 x 576 374 x 160 343 x 160 1029 x 480 1500x700 drawn at 1029x480
Expanded island 1346.4 x 576 374 x 160 343 x 160 1029 x 480 1496x700 drawn at 1026x480
Compact leading 457.5 x 220 127.1 x 61.1 108 x 52 324 x 156 1492x700 drawn at 324x152; 900x600 in a 24x24 node drawn at 108x72
Compact trailing 457.5 x 220 127.1 x 61.1 108 x 52 324 x 156 1488x700 drawn at 324x152
Minimal 202.5 x 220 56.3 x 61.1 48 x 52 144 x 156 1484x700 drawn at 144x68; 900x600 in a 24x24 node drawn at 108x72

Each bound is about 85% of its limit or less. The limit is 1.2 x the surface's points x the screen scale, so a bound in points has the same margin at 2x. The Lock Screen bound also fits a 375-point phone (about 343 points wide). The run without bounds logged 24 "Max size exceeded" lines. With this change, the log has none on any surface. The Lock Screen draws the photo where the run without bounds drew a grey box.

Lock Screen picture sizes found earlier, before this change:

Picture Before
900x600 placeholder (Max size exceeded)
870x580 placeholder
864x576 placeholder (the limit is exclusive)
640x426 drawn
480x320 drawn

Tests

  • flutterflow_live_activity: the cards Swift / shrinks every picture to the bound of the surface it is on. It checks each surface's bound and that each bound stays at least 10% under the measured limit.
  • flutterflow_native_layout:
    • every picture is kept to the bound of the surface it is on
    • a picture with a fixed frame is kept just large enough to cover it
    • a shrunk picture is cached by picture, scale, bound and frame
    • a picture / in a fixed frame is drawn no larger than it
    • a picture / with one fixed side is drawn no larger than it only when contained
  • Each of these tests fails without the change.
  • dart analyze is clean, and all tests pass: 57 in native_layout, 154 in live_activity, 51 at the root.

Analytics

No new events. This changes generated Swift only. The visible change is that the picture appears instead of a grey box, and nothing reports image placeholders today.

🤖 Generated with Claude Code

ayushflow and others added 2 commits November 30, 2026 14:01
iOS draws a grey placeholder instead of a picture that is, on either side,
1.2 times the Live Activity's Lock Screen view (in pixels) or more. A
900x600 fallback asset was refused on a 3x iPhone ("Max size exceeded:
1346.4x576"), so the card showed a grey box. The old cap (900 px longest
side) did not keep the height under 576 px.

Every picture a card draws, the bundled asset and the picture the app
stored for an Image value, now goes through ffDrawable, which keeps each
side to 343 x 160 points at the screen's scale. Home screen widgets keep
their 900 px cap through the same helper (SwiftPictureBound).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ayushflow
ayushflow requested a review from sbis04 November 30, 2026 14:19

@sbis04 sbis04 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Lock Screen fix works, but the compact and minimal island still draw the grey placeholder: the archive limit is per surface, not the Lock Screen's.

Repro (iPhone 17 Pro simulator, iOS 26.5, this branch): a Custom card with a 900x600 asset on a 24x24 image in islandCompactLeading and islandMinimal. Start the card, background the app. ffDrawable shrinks it to 720x480 and the extension still refuses it, once per surface:

[com.apple.chrono:archiving] [12: 720x480] Max size exceeded: 457.500000x220.000000; using placeholder image

457.5x220 px is about 127x61 pt at 3x times 1.2, so any picture over roughly 380x180 px in those surfaces turns grey. This covers assets and stored Image values alike: a value whose largest node fills the Lock Screen is stored at 900 px.

Suggestion: shrink to the node's frame when it is fixed (a 24 pt node needs 72 px), otherwise to a bound for each surface rather than one for the whole host.

Nit: FFValueImage now redraws the picture on every body pass. FFAssetImage caches its result; this could cache by image and scale too.

Checked otherwise: the 343x160 Lock Screen bound math holds, home widgets keep the 900 px bound, and the CHANGELOG line is there.

ayushflow and others added 3 commits November 30, 2026 20:48
The archive limit is per surface, not the Lock Screen's: a 900x600 asset
in a 24x24 node on the compact and minimal island was shrunk to 720x480
and still refused ("Max size exceeded: 457.5x220").

- Each Custom card surface's view sets its own bound (the ffPictureBound
  environment value). Limits measured on an iPhone 17 Pro, iOS 26.5, 3x:
  Lock Screen and expanded 1346.4x576 px, each compact side 457.5x220,
  minimal 202.5x220. Bounds: 343x160 pt (Lock Screen, expanded), 108x52
  (compact), 48x52 (minimal), each about 85% of its limit or less. Home
  widgets keep the 900 px longest-side default.
- An image node with a fixed frame passes it to FFAssetImage and
  FFValueImage, and its picture is kept just large enough to cover it at
  the screen's scale (a 24 pt node needs 72 px at 3x). One fixed side
  bounds a contained picture only.
- FFAssetImage's cache key includes the bound and the frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A shrunk picture is cached by the picture's identity, the screen's scale,
the surface's bound and the node's frame, at most 16 entries (a few
pictures on up to five surfaces). An entry keeps a weak reference to its
source and is used only when that is the very same picture, so a new
picture that takes a freed one's address never gets its result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rame

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ayushflow

Copy link
Copy Markdown
Contributor Author

Thanks, the archive limit is per surface. All three points are fixed:

  • Compact and minimal island still grey (per-surface limit): 207eadc. Each Custom card surface's view now sets its own picture bound with the ffPictureBound environment value. I measured each surface's limit on an iPhone 17 Pro simulator (iOS 26.5, 3x) with shrinking turned off:

    • Lock Screen and expanded island: 1346.4x576 px
    • Each compact side: 457.5x220 px
    • Minimal island: 202.5x220 px

    The bounds are 343x160 pt (Lock Screen, expanded), 108x52 pt (compact) and 48x52 pt (minimal). Each is about 85% of its limit or less, at any scale. Home widgets keep the 900 px longest-side default. Test: shrinks every picture to the bound of the surface it is on (live_activity) and every picture is kept to the bound of the surface it is on (native_layout).

  • Shrink to the node's frame when it is fixed: 207eadc. The emitter passes a fixed image node's width:/height: to FFAssetImage and FFValueImage, and ffDrawable keeps the picture just large enough to cover it at the screen's scale. Your repro's 900x600 asset in a 24x24 node is now 108x72 on both compact leading and minimal. With both sides fixed, the larger side ratio is used. With one fixed side, only a .fit picture is bounded by it, because a cover or stretched picture fills the free side and can be drawn larger. Tests: a picture with a fixed frame is kept just large enough to cover it, a picture / in a fixed frame is drawn no larger than it, a picture / with one fixed side is drawn no larger than it only when contained. FFAssetImage's cache key now includes the bound and the frame.

  • Nit, FFValueImage redraws on every body pass: 58042e4. FFValueImage now caches the shrunk picture by the picture's identity, scale, bound and frame, with at most 16 entries. Each entry keeps a weak reference to its source and is only used for that same picture, so a new picture at a freed one's address never gets the old result. Test: a shrunk picture is cached by picture, scale, bound and frame.

On the simulator, your repro (900x600 asset in a 24x24 node on compact leading and minimal) plus a large picture with no fixed size on each of the five surfaces gave no "Max size exceeded" line. Without the bounds, the same card logged 24. The CHANGELOG entry is updated in f741327, and the PR description now has the measured table. All six new tests fail on fb1c6c6. dart analyze is clean, and all tests pass (native_layout 57, live_activity 154, root 51).

@ayushflow ayushflow changed the title Live Activity: shrink every picture to what a card can draw Live Activity: keep every picture to what its surface and its node can draw Nov 30, 2026
@ayushflow
ayushflow requested a review from sbis04 November 30, 2026 16:50

@sbis04 sbis04 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks. Re-ran the repro on f741327 (iPhone 17 Pro simulator, iOS 26.5), adding a fill/cover 900x600 asset on compact trailing. Every picture was permitted, no "Max size exceeded":

Surface Picture Archived
compact leading, 24x24 900x600 asset 108x72
minimal, 24x24 900x600 asset 108x72
compact trailing, fill/cover 900x600 asset 234x156
Lock Screen, 36x36 120x120 asset 108x108

Tests pass in all three packages, analyze clean.

Nit: home widgets change too. A fixed-size asset is now shrunk to its frame (a 40 pt node gets 120 px at 3x). That's harmless, but the CHANGELOG says home widgets "keep the 900 px longest side", which is now only true for images without a fixed size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ayushflow

Copy link
Copy Markdown
Contributor Author

Thanks. Fixed the CHANGELOG in 71cc69d: home screen widgets keep the 900 px longest side as their bound, and a fixed-size image node is now shrunk to just what covers it, as on a card (a 40-point image gets 120 pixels at 3x). Images without a fixed size are drawn as before. The PR description says the same.

@ayushflow
ayushflow merged commit 10d4425 into main Nov 30, 2026
1 check passed
@ayushflow ayushflow mentioned this pull request Nov 30, 2026
@ayushflow
ayushflow deleted the ayush/live-activity-image-size branch November 30, 2026 18:20
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.

2 participants