Repository navigation
Conversation
…tiable there The view-body guest is Foundation-free by design (GuestIR + EmbeddedJSON), but four things kept it at T2 (~11.7 MB brotli floor) on a real app: 1. runSwiftUILowering (and the UIKit cell lowering) pinned the guest convergence to `startTier: .t2Foundation`. Both now start at T0 and rely on the existing escalation on a real compile failure. PATCH_SWIFTUI_START_TIER / PATCH_SWIFTUI_MAX_TIER / PATCH_UIKIT_START_TIER / PATCH_UIKIT_MAX_TIER (t0|t1|t2) override per run for measurement and isolation. 2. The T0 manifests never defined FRONTIER_EMBEDDED, so the IR's guarded Codable conformances were compiled and every embedded build failed on "'Codable' is unavailable in embedded Swift". 3. With --allow-undefined, an embedded module that compares Strings or parses a Double links but imports _swift_stdlib_getNormData / getComposition / getDecompositionEntry and _swift_stdlib_strtod_clocale from `env`, which the SDK host never provides, so WasmKit refuses to instantiate it. The T0 manifest now links libswiftUnicodeDataTables from the embedded SDK, and the CHost target carries a strtod shim (T0 only; the full runtime defines it at T1/T2). 4. PATCH_SWIFTUI_ONLY=1 skips the default function-thunk module, whose generated JSON-ABI wrappers force T2 for the merged artifact; with no primary module the guest is promoted to module.wasm by the existing promoteGuestToPrimary path. PATCH_UIKIT=0 skips cell lowering. Measured on a 949-file SwiftUI app at d026e03: a 17-view subtree went from 13.2 MB brotli (T2 merge) to 111 KB; the whole app (702 views lowered, 802 exports, 5 isolated) ships as 340 KB brotli with only wasi_snapshot_preview1.random_get imported. Verified on an iOS simulator: the module downloaded, verified, activated, and its view_body exports overrode the native views.
Author
|
@jackguac Lmk if I should close this or can we get it in? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The view-body guest is Foundation-free by design (GuestIR +
EmbeddedJSON), but on a real app it always shipped at T2 (~11.7 MB brotli floor). Four things caused that; this PR fixes them together because each one alone still leaves the guest at T2 or un-instantiable.runSwiftUILowering(and the UIKit cell lowering) callconverge(..., startTier: .t2Foundation). They now start at T0 and rely on the existing escalation on a real compile failure.PATCH_SWIFTUI_START_TIER/PATCH_SWIFTUI_MAX_TIER/PATCH_UIKIT_START_TIER/PATCH_UIKIT_MAX_TIER(t0|t1|t2) override per run for measurement and T0 isolation.FRONTIER_EMBEDDEDnever defined. The IR guards itsCodableconformances behind#if !FRONTIER_EMBEDDED(seeConformance.swift), but neither T0 manifest passed the define, so every embedded build failed on'Codable' is unavailable in embedded Swift.envimports at T0. With--allow-undefined, a guest that compares Strings or parses a Double links but imports_swift_stdlib_getNormData/getComposition/getDecompositionEntryand_swift_stdlib_strtod_clocalefromenv, which the SDK host never provides, so WasmKit refuses to instantiate. The T0 manifest now linkslibswiftUnicodeDataTablesfrom the embedded SDK, and theCHosttarget carries astrtodshim written only at T0 (the full runtime defines it at T1/T2).PATCH_SWIFTUI_ONLY=1skips the default function-thunk module, whose generated JSON-ABI wrappers force T2 for the merged artifact; with no primary module the guest is promoted tomodule.wasmthrough the existingpromoteGuestToPrimarypath.PATCH_UIKIT=0skips cell lowering.Measured on a 949-file SwiftUI app at
d026e03:The resulting module imports only
wasi_snapshot_preview1.random_get. Verified on an iOS simulator with the unmodified PatchSDK atd026e03: the module downloaded, verified, activated, and itsview_bodyexports overrode the native views.Defaults changed by this PR: the guests now start at T0 (they escalate to T1/T2 exactly as the default module does, so nothing that compiled before stops compiling). The two
PATCH_*_ONLY/PATCH_UIKITknobs are opt-in.