Skip to content

Decode tiled ASTC snapshots seen on iOS 26 and 27 - #2887

Merged
abrignoni merged 2 commits into
abrignoni:mainfrom
charpy4n6:fix/ktx-tiled-snapshots
Nov 25, 2026
Merged

abrignoni merged 2 commits into
abrignoni:mainfrom
charpy4n6:fix/ktx-tiled-snapshots

Conversation

@charpy4n6

@charpy4n6 charpy4n6 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem

On an iOS 27.2 full file system extraction, every SplashBoard snapshot in App Snapshots rendered as horizontal streaks or a single flat colour (324 of 324).

The tiled layout is not specific to that release. In review it was also seen on iPhone 14 and iPhone 15 Pro images on iOS 26.3 and 26.5, which this change decodes correctly; iOS 18 images pass through unchanged. The iOS 27.2 extraction below is the one this PR was built and measured against.

The AAPL magic, the HEAD layout, ASTC 4x4 and the pixel sizes are unchanged. Two things did change:

  • The chunk list. The iOS 17 snapshots compared carry HEAD, FILL (136 bytes), LZFS, END , with LZFSE-compressed data starting at 0x100. The iOS 27.2 ones carry HEAD, FILL (16,264 bytes), astc, END , with uncompressed data starting at 0x4000. The reader already handled both chunk types, so this needed no change.
  • The block layout, which is what broke the images: blocks are held in tiles of 32x32 blocks, Morton (Z) ordered inside each tile, on a surface padded to whole tiles, followed by one more block. A 1170x2532 snapshot needs 185,469 blocks, and the file holds 204,801 (320x640 + 1). KTX_reader passed the data to the decoder in raster order.

Change

KTX_reader.untile_astc_4x4 (in scripts/ktx/ios_ktx2png.py) returns AAPL texture data in raster order, so App Snapshots, Widgets and the Messages preview artifact all pick it up.

  • The block count decides. Data holding exactly one block per 4x4 pixels (every older file checked) is returned unchanged; the old path is not removed.
  • Only when the image is whole tiles, so the padded and exact counts are equal, is HEAD word 12 read: it was 1 in every tiled file and 0 in every linear file observed. Apple does not document it; this is an observation, not a documented meaning, and no real file needed this branch.
  • Khronos KTX1 files take a separate, unchanged path.

Verification

Data-proven on three local extractions, with texture2ddecoder as an independent second decoder:

extraction snapshots widget snapshots result
iOS 27.2 324 tiled 24 linear no ASTC error blocks; both decoders agree
iOS 17 106 linear 6 linear unchanged, both decoders agree
older iOS 262 linear 11 linear unchanged, both decoders agree

After the fix, 193 of the iOS 27.2 snapshots are a single colour in both decoders (plain launch screens). Before it, only the iLEAPP decoder showed them flat, so that is a property of the files, not of the decode.

A run of iLEAPP with only App Snapshots against the iOS 27.2 zip reports 324 rows, with correct images.

admin/test/scripts/test_ktx_tiled_layout.py round-trips synthetic block data through the tiled layout (portrait, landscape, tile-aligned with the HEAD word) and asserts linear data passes through untouched.

Not covered:

  • A variant with the same tiles but the Morton x and y bits swapped, reported in review on an iPhone 11 image on iOS 26.2.1. Nothing in the file was found to say which order applies, so its snapshots with visible content are still scrambled, as before. To be handled in a separate PR.
  • None of the registered corpora in admin/image_manifest.json were available locally, so the recorded sample_data counts were not re-run.

🤖 Generated with Claude Code

SplashBoard snapshot KTX files on an iOS 27.2 extraction hold their ASTC 4x4
blocks in 32x32-block tiles, Morton ordered inside each tile, on a surface
padded to whole tiles plus one block. The reader passed them to the decoder
in raster order, so all 324 snapshots in that extraction rendered as streaks
or a single flat colour.

KTX_reader now returns AAPL texture data in raster order. The block count
decides the layout; HEAD word 12, 1 in every tiled file and 0 in every
linear file observed, is read only when the counts cannot tell them apart.
Linear files are returned unchanged.

Checked on one iOS 27.2 and two older extractions: 324 tiled and 368
linear snapshots, plus 41 linear widget snapshots, decode with no ASTC
error blocks and agree with texture2ddecoder as an independent decoder.
App Snapshots still reports 324 rows on iOS 27.2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the mac-review Enrolled for review on the maintainer’s Mac label Nov 25, 2026

@abrignoni abrignoni left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Automated iLEAPP review.

Comment thread scripts/ktx/ios_ktx2png.py Resolved
@abrignoni

Copy link
Copy Markdown
Owner

Thanks for this one. I ran it against our corpus and it fixes more than iOS 27.2. iPhone 14 and iPhone 15 Pro images on iOS 26.3 and 26.5 have the same tiled layout, and their snapshots now decode correctly. iOS 18 images pass through unchanged.

Could you update the title, the description and the untile_astc_4x4 docstring so they don't tie the tiled layout to iOS 27.2? "Seen on iOS 26 and 27" covers what we have.

One thing that is out of scope here: an iPhone 11 image on iOS 26.2.1 uses the same tiles with the Morton x and y bits swapped, so its snapshots with visible content are still scrambled, as they were before. I haven't found a field in the file that says which order applies, so I'll handle that in a separate PR after this one merges.

Review found the same tiled layout on iOS 26.3 and 26.5 images, so the
docstring and tests no longer tie it to iOS 27.2. The docstring also
states the Morton bit order and names the swapped-bit variant reported
on an iOS 26.2.1 image, which this change does not handle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@charpy4n6 charpy4n6 changed the title Decode tiled ASTC snapshots written by iOS 27.2 Decode tiled ASTC snapshots seen on iOS 26 and 27 Nov 25, 2026
@charpy4n6

Copy link
Copy Markdown
Contributor Author

Thanks for running it against the corpus. Updated:

  • Title is now "Decode tiled ASTC snapshots seen on iOS 26 and 27".
  • The description says the layout was also seen on iOS 26.3 and 26.5 (iPhone 14, iPhone 15 Pro), with iOS 18 unchanged. It keeps the iOS 27.2 extraction as the one the measurements came from.
  • The untile_astc_4x4 docstring says "seen on iOS 26 and 27" and states the bit order (x in the even bits, y in the odd). The test file's wording matches (711a487).
  • The swapped-bit variant on the iPhone 11 / iOS 26.2.1 image is listed as not covered, both in the description and in the docstring, so nobody reads this PR as handling it. I'll leave the fix to your follow-up.

charpy4n6 added a commit to charpy4n6/leapps-website that referenced this pull request Nov 25, 2026
Review of abrignoni/iLEAPP#2887 found the tiled layout on iOS 26.3 and
26.5 images, and a variant with the Morton x and y bits swapped on an
iOS 26.2.1 image that the fix does not handle.

- Retitle the post and rename its slug and image folder so they no
  longer tie the layout to iOS 27.
- Say the version alone does not decide the layout, and name the
  swapped-bit variant as not handled.
- Limit the re-run advice to snapshots in the tiled layout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@abrignoni
abrignoni merged commit 3c7ac1e into abrignoni:main Nov 25, 2026
27 checks passed
@charpy4n6

Copy link
Copy Markdown
Contributor Author

A correction to the description above, for anyone reading it later.

It says every snapshot in the iOS 27.2 extraction "rendered as horizontal streaks or a single flat colour (324 of 324)". That is literally true, but it reads as if all 324 were broken, and they were not. Decoding every snapshot before and after this change and comparing them pixel for pixel:

before after count
single colour identical single colour 193
streaks correct picture 131

The 193 single-colour snapshots are plain launch and placeholder screens, and iLEAPP was already showing them correctly: a one-colour picture looks the same whatever order its blocks are in. Only the 131 with real content were broken, and those are what this PR fixed. The code and its verification are unaffected.

The leapps.org post (abrignoni/leapps-website#331) has been corrected to match.

abrignoni pushed a commit to abrignoni/leapps-website that referenced this pull request Nov 25, 2026
Explains why App Snapshots rendered as streaks or flat colour on an
iOS 27.2 extraction (ASTC blocks in 32x32-block Morton-ordered tiles on
a padded surface) and how iLEAPP now reads both layouts
(abrignoni/iLEAPP#2887). Includes a diagram of the block order.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mac-review Enrolled for review on the maintainer’s Mac

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants