[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74XASMT2B3XEYN9DNJ20ET9":3,"skill-same:01M74XASMT2B3XEYN9DNJ20ET9":43},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":13,"repositoryHtmlUrl":26,"repositoryHomepageUrl":6,"ownerHtmlUrl":27,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":28,"install":29,"resources":42},"01M74XASMT2B3XEYN9DNJ20ET9","realitykit-windowed-view-ios-gotchas",null,"Building or debugging a RealityKit RealityView in a windowed iOS\u002FiPadOS app (NOT visionOS) — a 3D companion view next to existing 2D UI, a scene mounted in a sheet or fullScreenCover, or any windowed .virtual-camera scene. Covers the fullScreenCover black-feed bug and its real fix, camera framing per presentation context, scene-rebuild-on-drift architecture, and the tiered-fidelity design decision (unlit-safe vs lit-PBR-risk) for shipping a 3D view that must not go blank. Use this whenever the user mentions RealityKit, RealityView, ARView, a 3D scene\u002Frack\u002Fmap\u002Fviewer on iPhone or iPad, a blank\u002Fblack 3D render, or \"make this look like the 3D mockup\" for a non-visionOS target — even if they don't say \"RealityKit\" explicitly.","abhijitbansal\u002Fclaude-skills","abhijitbansal","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F271802621?v=4","01M74XA5M33XYNJ2D2TJDS7W9E","01M74XA5MQ8GMWJW10ZJ4V0NVG",1,"MIT","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Farchive\u002Flearned-skills\u002Frealitykit-windowed-view-ios-gotchas\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: realitykit-windowed-view-ios-gotchas\ndescription: Building or debugging a RealityKit RealityView in a windowed iOS\u002FiPadOS app (NOT visionOS) — a 3D companion view next to existing 2D UI, a scene mounted in a sheet or fullScreenCover, or any windowed .virtual-camera scene. Covers the fullScreenCover black-feed bug and its real fix, camera framing per presentation context, scene-rebuild-on-drift architecture, and the tiered-fidelity design decision (unlit-safe vs lit-PBR-risk) for shipping a 3D view that must not go blank. Use this whenever the user mentions RealityKit, RealityView, ARView, a 3D scene\u002Frack\u002Fmap\u002Fviewer on iPhone or iPad, a blank\u002Fblack 3D render, or \"make this look like the 3D mockup\" for a non-visionOS target — even if they don't say \"RealityKit\" explicitly.\n---\n\n# RealityKit Windowed RealityView on iOS (Not visionOS)\n\nApple's RealityView\u002FRealityKit docs and sample code are written against visionOS\nassumptions (an immersive space, always-on stereo rendering, no concept of a\nsheet or fullScreenCover racing a scene's first frame). Every one of those\nassumptions silently breaks in a windowed iPhone\u002FiPad app. This skill is the\naccumulated, sim-verified fix set from building a rack\u002Fbin 3D viewer — treat it\nas the starting checklist any time a RealityView needs to render correctly and\nconsistently on iOS, not just \"usually.\"\n\n## Gotcha 1 — `attachments:` is visionOS-only\n\n`RealityView { content, attachments in }` with a SwiftUI `attachments:` closure\n(compositing SwiftUI views into the 3D scene) is not available in the windowed\niOS presentation. For in-scene labels, render text as geometry instead:\n\n```swift\nlet mesh = MeshResource.generateText(shortCode, extrusionDepth: 0.002,\n                                      font: .systemFont(ofSize: 0.14, weight: .semibold))\nlet label = ModelEntity(mesh: mesh, materials: [UnlitMaterial(color: .white)])\n\u002F\u002F Billboard it every `update:` pass so it keeps facing the camera — see Gotcha 4.\n```\n\n## Gotcha 2 — no default camera gestures in windowed mode\n\nOrbit\u002Fpinch is not free. Opt in explicitly:\n\n```swift\nRealityView { content in ... }\n    .realityViewCameraControls(.orbit)   \u002F\u002F otherwise the scene is frozen\n```\nIf you need custom framing per mount (Gotcha 6) or your own pinch handling,\nyou may skip this and drive the camera transform yourself instead.\n\n## Gotcha 3 — a `.virtual`-camera RealityView mounted inside a *still-presenting* `fullScreenCover` renders solid black\n\nThis is the big one, and the first fix most people reach for is wrong.\n\n**Symptom:** the identical `RackScene3DView` renders correctly inline (in a\nsheet, in a `List` row, embedded in another screen) but is a **solid black\nfeed with zero content** the moment it's the root of a `fullScreenCover`. Not\nnavy, not empty-but-lit — fully black, as if nothing was ever added to the\nscene.\n\n**The fix everyone tries first — wrapping in `GeometryReader` and handing the\n`RealityView` concrete `width`\u002F`height` — does not work.** It's a reasonable\nhypothesis (ambiguous size at `make:` time) but it is **not the actual cause**,\nand shipping it will cost you a full diagnostic-and-fix cycle before you find\nout. Prove this to yourself with a sim screenshot before trusting either\nfix: force the presentation you're debugging, screenshot it, and only then\nchange code — see the diagnostic protocol below.\n\n**Root cause (verified twice, independently, in two different features):** a\n`.virtual`-camera `RealityView` created as the root of a `fullScreenCover`\n*while the cover is still animating its presentation* never establishes a\nrender surface. `make:` runs exactly once, on that bad frame, and nothing\nafter — including a later resize — recovers it. This is Apple's own bug\n(FB22536529 \u002F FB22537390 family, the non-AR `.virtual`-camera variant of a\npublicly-reported \"RealityView black as a modal root\" issue:\ndeveloper.apple.com\u002Fforums\u002Fthread\u002F786543). No published fix as of iOS 26;\nre-test on every new iOS major before assuming it's still needed.\n\n**The real fix: defer mounting past the present animation, not past a layout pass.**\n\n```swift\n@State private var is3DReady = false\n\nprivate enum Layout {\n    \u002F\u002F\u002F Long enough to clear the fullScreenCover present animation so\n    \u002F\u002F\u002F RealityKit has a live render surface at `make:` time.\n    static let scene3DMountDelayMilliseconds = 500\n}\n\nvar body: some View {\n    GeometryReader { geometry in\n        if is3DReady, geometry.size.width > 0, geometry.size.height > 0 {\n            RackScene3DView(rack: rack, mode: .browse(onSelect: selectAndDismiss))\n                .frame(width: geometry.size.width, height: geometry.size.height)\n        } else {\n            Color.black   \u002F\u002F masks the mount delay; matches the eventual scene bg\n        }\n    }\n    .task {\n        guard !is3DReady else { return }\n        try? await Task.sleep(for: .milliseconds(Layout.scene3DMountDelayMilliseconds))\n        guard !Task.isCancelled else { return }   \u002F\u002F see Gotcha 5\n        is3DReady = true\n    }\n}\n```\n\nThe `GeometryReader`'s `width > 0`\u002F`height > 0` guard is still worth keeping\n(cheap, correct), but it is not what fixes the black feed — the `.task` delay\nis. Leave inline mounts (sheet, List row) completely untouched; they already\nrender because they're never inside a still-presenting cover.\n\n**Trade-off:** ~500ms of `Color.black` before the scene appears. Acceptable;\ntune the constant if a slower device needs more headroom, but don't remove the\ndelay to \"fix\" the flash — that reintroduces the black feed.\n\n## Gotcha 4 — scene must rebuild on data drift, not just once in `make:`\n\nHold scene state in one reference-type `@State` object (a \"SceneStore\" \u002F\n\"ObservableStore\" pattern), and diff drift-relevant inputs in `update:`,\nrebuilding only what changed:\n\n```swift\n@Observable\nfinal class SceneStore {\n    var rootEntity = Entity()      \u002F\u002F bins — rebuilt by rebuildScene on drift\n    var cameraEntity = Entity()\n    var frameContainer = Entity()  \u002F\u002F structural chrome — rebuilt separately, see Gotcha 7\n    var builtBoxes: [BinBox] = []\n    var builtHighlightID: UUID?\n}\n\nRealityView { content in\n    content.add(store.cameraEntity)\n    content.add(store.rootEntity)\n    content.add(store.frameContainer)\n    rebuildScene(...)      \u002F\u002F first build\n} update: { content in\n    guard boxes != store.builtBoxes || highlightID != store.builtHighlightID else { return }\n    rebuildScene(...)      \u002F\u002F only on drift — `make:`-only assembly goes stale\n                            \u002F\u002F on any subsequent SwiftUI re-render\n}\n```\n\n`make:`-only assembly is the second most common mistake after Gotcha 3: it\nlooks correct on first render and only breaks once something in the model\nchanges while the view stays mounted.\n\n## Gotcha 5 — guard a mount-defer `.task` against cancellation\n\nIf Gotcha 3's fix is a `.task` that flips a readiness flag after a sleep, a\nuser can toggle away from the 3D view mid-sleep and cancel that task. `try?`\naround `Task.sleep` **swallows** `CancellationError` — without an explicit\ncheck, the flag flips `true` on a torn-down subtree anyway:\n\n```swift\ntry? await Task.sleep(for: .milliseconds(Layout.scene3DMountDelayMilliseconds))\nguard !Task.isCancelled else { return }   \u002F\u002F NOT optional — see below\nis3DReady = true\n```\n\nWithout this guard: rapid toggle A→B→A skips the present-clearance delay on\nthe second entry into A (the flag was already `true` from the cancelled first\nattempt), which can resurrect the exact black-feed race from Gotcha 3. This\nbug is invisible in a slow manual test and only shows up under fast\nprogrammatic or impatient-user toggling — write a test or a scripted\nsim-toggle for it, don't rely on eyeballing.\n\n## Gotcha 6 — structural\u002Fchrome geometry needs its own rebuild container, separate from per-item content\n\nIf the scene has both per-item entities (bins, rows — driven by a data\ncollection) *and* structural chrome that depends on a different input (a rack\nframe, shelf planks, whose shape depends on grid dimensions, not on which\nitems exist), **do not add the chrome to the same root entity you clear and\nrebuild for item changes.** It'll either get wiped on every item rebuild\n(wasteful) or never rebuilt at all when its own input changes (stale frame\naround a resized grid):\n\n```swift\n\u002F\u002F SceneStore\nvar rootEntity = Entity()        \u002F\u002F items — cleared\u002Frebuilt by rebuildScene\nvar frameContainer = Entity()    \u002F\u002F chrome — its OWN container, added to content once\nvar builtShelfCount = -1         \u002F\u002F -1 forces the first rebuildFrame to run even for 0×0\nvar builtColumnCount = -1\n\n\u002F\u002F make: — add both containers once\ncontent.add(store.rootEntity)\ncontent.add(store.frameContainer)\nrebuildFrame(shelfCount: layout.rows.count, columnCount: layout.rows.first?.count ?? 0)\n\n\u002F\u002F update: — each container rebuilds independently, on its own drift condition\nif shelfCount != store.builtShelfCount || columnCount != store.builtColumnCount {\n    rebuildFrame(shelfCount: shelfCount, columnCount: columnCount)   \u002F\u002F chrome\n}\n\u002F\u002F ...rebuildScene(...) for items, gated on its own diff (Gotcha 4)\n\nprivate func rebuildFrame(shelfCount: Int, columnCount: Int) {\n    store.frameContainer.children.removeAll()   \u002F\u002F mutate the container in place —\n    for frame in makeFrameEntities(shelfCount: shelfCount, columnCount: columnCount) {\n        store.frameContainer.addChild(frame)    \u002F\u002F no `content` handle needed post-mount\n    }\n    store.builtShelfCount = shelfCount\n    store.builtColumnCount = columnCount\n}\n```\n\nThe tell that you need this split: chrome that's sized\u002Fshaped from\n*configuration* (grid dimensions, layout mode) while items are sized\u002Fshaped\nfrom a *collection* (which bins exist) will drift out of sync the moment\nconfiguration changes while the view stays mounted — e.g. editing a rack's\nshelf count while its inline 3D map is still on screen.\n\n## Gotcha 7 — camera framing is presentation-context-dependent, not scene-dependent\n\nThe same scene needs a different default camera distance depending on where\nit's mounted, because the *viewport aspect ratio* differs — an inline mount in\na card is roughly square-ish; a full-screen cover in portrait is tall and\nnarrow, and the same \"distance that frames a wide rack nicely inline\" clips\nthe outer edges in portrait full-screen.\n\nMake the starting radius an init parameter with a per-mount default, not a\nsingle shared constant:\n\n```swift\nenum ScanConstants {\n    static let rack3DDefaultRadius: Float = 2.0        \u002F\u002F inline framing\n    static let rack3DFullScreenRadius: Float = 2.9      \u002F\u002F dollied back for portrait\n}\n\ninit(rack: Rack, mode: Mode, initialRadius: Float = ScanConstants.rack3DDefaultRadius) { ... }\n\n\u002F\u002F full-screen call site:\nRackScene3DView(rack: rack, mode: .browse(...), initialRadius: ScanConstants.rack3DFullScreenRadius)\n```\nPinch\u002Forbit still re-dollies within existing min\u002Fmax clamps from either\nstarting point — this only fixes the *first-frame* framing, which is what a\nscreenshot or a user's first glance actually judges.\n\n## Gotcha 8 — verification settle time is longer than the mount delay\n\nIf Gotcha 3's fix adds a ~500ms mount defer, a screenshot taken at, say, 4\nseconds after triggering the presentation can still land mid-transition and\nlook blank — not because the fix failed, but because the cover's own present\nanimation plus the mount defer plus first-frame render adds up to more than a\nfew seconds end-to-end on a simulator. Settle **≥6 seconds** before trusting a\n\"still blank\" screenshot as a real failure; re-shoot before debugging further.\n\n## Architecture decisions — building the *feature*, not just the view\n\nThese are product\u002Farchitecture calls this project made and the reasoning\nbehind them — apply the same reasoning, not necessarily the same choice, to a\ndifferent app's constraints.\n\n**Tiered fidelity: ship the unlit tier first; treat lit PBR as separately-risked, optional polish.**\nA `UnlitMaterial`\u002Femissive-only scene cannot go dark or blank from a lighting\nproblem — it has no lighting dependency to break. A scene built from\n`PhysicallyBasedMaterial` + `DirectionalLight`\u002F`PointLight` entities can\nrender solid black or fully dark if a light entity fails to attach, a shadow\nsetting misbehaves, or ambient\u002FIBL isn't configured — and that failure mode is\nmuch harder to diagnose than \"the render is dim.\" When a fully-lit,\nshadowed, particle-effects tier is the *stated* goal, still ship the unlit\nstructural tier as the safe baseline first (translucent materials, flat\ncolor, no light entities at all can still look intentional and premium — see\n`ScanConstants`-style hex-matched colors pulled from a design reference), and\ngate the lit tier as an explicit, separately-tested follow-up. This is a\ndirect trade of \"matches the mockup exactly\" against \"cannot regress to a\nworse state than before the feature existed\" — bias toward the latter for a\nfirst ship.\n\n**The 2D view stays the accessible source of truth; 3D is a sighted-only enhancement.**\nIf the feature has both a flat\u002F2D representation and a 3D one, keep them\nbacked by the **same** data-model and layout-building code (one\n`RackMapBuilder`\u002F`RackMapLayout`-equivalent used by both renderers, so they\ncan never disagree about what exists or where it sits), mark the 3D scene's\ncontainer `.accessibilityHidden` where appropriate, and never let a\ncapability (tap-to-open, quick placement, drag) exist in 3D-only. Users with\nVoiceOver, Reduce Motion, or devices where the 3D tier degrades should get a\nfully-functional experience from the 2D view alone.\n\n**Tier-honesty: when you ship less than the chosen tier, say so explicitly.**\nIf a user picks \"Full fidelity\" (lit PBR, shadows, particles) but the safe\nunlit tier is what actually ships this round, that is a legitimate\nengineering call given Gotcha above — but say so as an explicit\naccept-vs-attempt decision (\"delivered X of the 5 Full-tier items; Y\u002FZ\ndeferred because \u003Crisk>\") rather than silently reporting the lesser tier as\n\"Full re-skin done.\" Catching your own tier-downgrade before the user does is\ncheaper than them catching it on device.\n\n## Diagnostic protocol (don't skip this before picking a fix)\n\nWhen a RealityView renders wrong in only *some* mounts:\n1. List every mount (inline card, sheet, `List` row, `fullScreenCover`, etc.)\n2. Force the feature on and screenshot **each** mount independently (a debug\n   seed + forced `UserDefaults` flag + `xcrun simctl io \u003Cudid> screenshot` is\n   usually the fastest harness).\n3. Record exactly which mounts render and which don't — the pattern (e.g.\n   \"only the fullScreenCover fails\") tells you the cause; guessing from the\n   code alone before this step reliably picks the wrong hypothesis first\n   (see Gotcha 3).\n4. Only then change code, and re-screenshot the *specific* mount you fixed\n   with ≥6s settle (Gotcha 8) before calling it done.\n\n## Related skills\n- `subagent-buildverify-tool-grant-check` — if you're delegating this\n  diagnostic\u002Ffix cycle to a subagent, confirm it actually has a shell before\n  handing it a \"screenshot and verify\" acceptance test.\n- `swiftui-tabbar-swipe-nav-tradeoff` — if this 3D view sits behind a custom\n  tab bar \u002F pager, that skill's Part 3 (pushed-scroll clearance) is a\n  related-but-separate SwiftUI layout gotcha in the same feature area.\n","# RealityKit Windowed RealityView on iOS (Not visionOS)\n\nApple's RealityView\u002FRealityKit docs and sample code are written against visionOS\nassumptions (an immersive space, always-on stereo rendering, no concept of a\nsheet or fullScreenCover racing a scene's first frame). Every one of those\nassumptions silently breaks in a windowed iPhone\u002FiPad app. This skill is the\naccumulated, sim-verified fix set from building a rack\u002Fbin 3D viewer — treat it\nas the starting checklist any time a RealityView needs to render correctly and\nconsistently on iOS, not just \"usually.\"\n\n## Gotcha 1 — `attachments:` is visionOS-only\n\n`RealityView { content, attachments in }` with a SwiftUI `attachments:` closure\n(compositing SwiftUI views into the 3D scene) is not available in the windowed\niOS presentation. For in-scene labels, render text as geometry instead:\n\n```swift\nlet mesh = MeshResource.generateText(shortCode, extrusionDepth: 0.002,\n                                      font: .systemFont(ofSize: 0.14, weight: .semibold))\nlet label = ModelEntity(mesh: mesh, materials: [UnlitMaterial(color: .white)])\n\u002F\u002F Billboard it every `update:` pass so it keeps facing the camera — see Gotcha 4.\n```\n\n## Gotcha 2 — no default camera gestures in windowed mode\n\nOrbit\u002Fpinch is not free. Opt in explicitly:\n\n```swift\nRealityView { content in ... }\n    .realityViewCameraControls(.orbit)   \u002F\u002F otherwise the scene is frozen\n```\nIf you need custom framing per mount (Gotcha 6) or your own pinch handling,\nyou may skip this and drive the camera transform yourself instead.\n\n## Gotcha 3 — a `.virtual`-camera RealityView mounted inside a *still-presenting* `fullScreenCover` renders solid black\n\nThis is the big one, and the first fix most people reach for is wrong.\n\n**Symptom:** the identical `RackScene3DView` renders correctly inline (in a\nsheet, in a `List` row, embedded in another screen) but is a **solid black\nfeed with zero content** the moment it's the root of a `fullScreenCover`. Not\nnavy, not empty-but-lit — fully black, as if nothing was ever added to the\nscene.\n\n**The fix everyone tries first — wrapping in `GeometryReader` and handing the\n`RealityView` concrete `width`\u002F`height` — does not work.** It's a reasonable\nhypothesis (ambiguous size at `make:` time) but it is **not the actual cause**,\nand shipping it will cost you a full diagnostic-and-fix cycle before you find\nout. Prove this to yourself with a sim screenshot before trusting either\nfix: force the presentation you're debugging, screenshot it, and only then\nchange code — see the diagnostic protocol below.\n\n**Root cause (verified twice, independently, in two different features):** a\n`.virtual`-camera `RealityView` created as the root of a `fullScreenCover`\n*while the cover is still animating its presentation* never establishes a\nrender surface. `make:` runs exactly once, on that bad frame, and nothing\nafter — including a later resize — recovers it. This is Apple's own bug\n(FB22536529 \u002F FB22537390 family, the non-AR `.virtual`-camera variant of a\npublicly-reported \"RealityView black as a modal root\" issue:\ndeveloper.apple.com\u002Fforums\u002Fthread\u002F786543). No published fix as of iOS 26;\nre-test on every new iOS major before assuming it's still needed.\n\n**The real fix: defer mounting past the present animation, not past a layout pass.**\n\n```swift\n@State private var is3DReady = false\n\nprivate enum Layout {\n    \u002F\u002F\u002F Long enough to clear the fullScreenCover present animation so\n    \u002F\u002F\u002F RealityKit has a live render surface at `make:` time.\n    static let scene3DMountDelayMilliseconds = 500\n}\n\nvar body: some View {\n    GeometryReader { geometry in\n        if is3DReady, geometry.size.width > 0, geometry.size.height > 0 {\n            RackScene3DView(rack: rack, mode: .browse(onSelect: selectAndDismiss))\n                .frame(width: geometry.size.width, height: geometry.size.height)\n        } else {\n            Color.black   \u002F\u002F masks the mount delay; matches the eventual scene bg\n        }\n    }\n    .task {\n        guard !is3DReady else { return }\n        try? await Task.sleep(for: .milliseconds(Layout.scene3DMountDelayMilliseconds))\n        guard !Task.isCancelled else { return }   \u002F\u002F see Gotcha 5\n        is3DReady = true\n    }\n}\n```\n\nThe `GeometryReader`'s `width > 0`\u002F`height > 0` guard is still worth keeping\n(cheap, correct), but it is not what fixes the black feed — the `.task` delay\nis. Leave inline mounts (sheet, List row) completely untouched; they already\nrender because they're never inside a still-presenting cover.\n\n**Trade-off:** ~500ms of `Color.black` before the scene appears. Acceptable;\ntune the constant if a slower device needs more headroom, but don't remove the\ndelay to \"fix\" the flash — that reintroduces the black feed.\n\n## Gotcha 4 — scene must rebuild on data drift, not just once in `make:`\n\nHold scene state in one reference-type `@State` object (a \"SceneStore\" \u002F\n\"ObservableStore\" pattern), and diff drift-relevant inputs in `update:`,\nrebuilding only what changed:\n\n```swift\n@Observable\nfinal class SceneStore {\n    var rootEntity = Entity()      \u002F\u002F bins — rebuilt by rebuildScene on drift\n    var cameraEntity = Entity()\n    var frameContainer = Entity()  \u002F\u002F structural chrome — rebuilt separately, see Gotcha 7\n    var builtBoxes: [BinBox] = []\n    var builtHighlightID: UUID?\n}\n\nRealityView { content in\n    content.add(store.cameraEntity)\n    content.add(store.rootEntity)\n    content.add(store.frameContainer)\n    rebuildScene(...)      \u002F\u002F first build\n} update: { content in\n    guard boxes != store.builtBoxes || highlightID != store.builtHighlightID else { return }\n    rebuildScene(...)      \u002F\u002F only on drift — `make:`-only assembly goes stale\n                            \u002F\u002F on any subsequent SwiftUI re-render\n}\n```\n\n`make:`-only assembly is the second most common mistake after Gotcha 3: it\nlooks correct on first render and only breaks once something in the model\nchanges while the view stays mounted.\n\n## Gotcha 5 — guard a mount-defer `.task` against cancellation\n\nIf Gotcha 3's fix is a `.task` that flips a readiness flag after a sleep, a\nuser can toggle away from the 3D view mid-sleep and cancel that task. `try?`\naround `Task.sleep` **swallows** `CancellationError` — without an explicit\ncheck, the flag flips `true` on a torn-down subtree anyway:\n\n```swift\ntry? await Task.sleep(for: .milliseconds(Layout.scene3DMountDelayMilliseconds))\nguard !Task.isCancelled else { return }   \u002F\u002F NOT optional — see below\nis3DReady = true\n```\n\nWithout this guard: rapid toggle A→B→A skips the present-clearance delay on\nthe second entry into A (the flag was already `true` from the cancelled first\nattempt), which can resurrect the exact black-feed race from Gotcha 3. This\nbug is invisible in a slow manual test and only shows up under fast\nprogrammatic or impatient-user toggling — write a test or a scripted\nsim-toggle for it, don't rely on eyeballing.\n\n## Gotcha 6 — structural\u002Fchrome geometry needs its own rebuild container, separate from per-item content\n\nIf the scene has both per-item entities (bins, rows — driven by a data\ncollection) *and* structural chrome that depends on a different input (a rack\nframe, shelf planks, whose shape depends on grid dimensions, not on which\nitems exist), **do not add the chrome to the same root entity you clear and\nrebuild for item changes.** It'll either get wiped on every item rebuild\n(wasteful) or never rebuilt at all when its own input changes (stale frame\naround a resized grid):\n\n```swift\n\u002F\u002F SceneStore\nvar rootEntity = Entity()        \u002F\u002F items — cleared\u002Frebuilt by rebuildScene\nvar frameContainer = Entity()    \u002F\u002F chrome — its OWN container, added to content once\nvar builtShelfCount = -1         \u002F\u002F -1 forces the first rebuildFrame to run even for 0×0\nvar builtColumnCount = -1\n\n\u002F\u002F make: — add both containers once\ncontent.add(store.rootEntity)\ncontent.add(store.frameContainer)\nrebuildFrame(shelfCount: layout.rows.count, columnCount: layout.rows.first?.count ?? 0)\n\n\u002F\u002F update: — each container rebuilds independently, on its own drift condition\nif shelfCount != store.builtShelfCount || columnCount != store.builtColumnCount {\n    rebuildFrame(shelfCount: shelfCount, columnCount: columnCount)   \u002F\u002F chrome\n}\n\u002F\u002F ...rebuildScene(...) for items, gated on its own diff (Gotcha 4)\n\nprivate func rebuildFrame(shelfCount: Int, columnCount: Int) {\n    store.frameContainer.children.removeAll()   \u002F\u002F mutate the container in place —\n    for frame in makeFrameEntities(shelfCount: shelfCount, columnCount: columnCount) {\n        store.frameContainer.addChild(frame)    \u002F\u002F no `content` handle needed post-mount\n    }\n    store.builtShelfCount = shelfCount\n    store.builtColumnCount = columnCount\n}\n```\n\nThe tell that you need this split: chrome that's sized\u002Fshaped from\n*configuration* (grid dimensions, layout mode) while items are sized\u002Fshaped\nfrom a *collection* (which bins exist) will drift out of sync the moment\nconfiguration changes while the view stays mounted — e.g. editing a rack's\nshelf count while its inline 3D map is still on screen.\n\n## Gotcha 7 — camera framing is presentation-context-dependent, not scene-dependent\n\nThe same scene needs a different default camera distance depending on where\nit's mounted, because the *viewport aspect ratio* differs — an inline mount in\na card is roughly square-ish; a full-screen cover in portrait is tall and\nnarrow, and the same \"distance that frames a wide rack nicely inline\" clips\nthe outer edges in portrait full-screen.\n\nMake the starting radius an init parameter with a per-mount default, not a\nsingle shared constant:\n\n```swift\nenum ScanConstants {\n    static let rack3DDefaultRadius: Float = 2.0        \u002F\u002F inline framing\n    static let rack3DFullScreenRadius: Float = 2.9      \u002F\u002F dollied back for portrait\n}\n\ninit(rack: Rack, mode: Mode, initialRadius: Float = ScanConstants.rack3DDefaultRadius) { ... }\n\n\u002F\u002F full-screen call site:\nRackScene3DView(rack: rack, mode: .browse(...), initialRadius: ScanConstants.rack3DFullScreenRadius)\n```\nPinch\u002Forbit still re-dollies within existing min\u002Fmax clamps from either\nstarting point — this only fixes the *first-frame* framing, which is what a\nscreenshot or a user's first glance actually judges.\n\n## Gotcha 8 — verification settle time is longer than the mount delay\n\nIf Gotcha 3's fix adds a ~500ms mount defer, a screenshot taken at, say, 4\nseconds after triggering the presentation can still land mid-transition and\nlook blank — not because the fix failed, but because the cover's own present\nanimation plus the mount defer plus first-frame render adds up to more than a\nfew seconds end-to-end on a simulator. Settle **≥6 seconds** before trusting a\n\"still blank\" screenshot as a real failure; re-shoot before debugging further.\n\n## Architecture decisions — building the *feature*, not just the view\n\nThese are product\u002Farchitecture calls this project made and the reasoning\nbehind them — apply the same reasoning, not necessarily the same choice, to a\ndifferent app's constraints.\n\n**Tiered fidelity: ship the unlit tier first; treat lit PBR as separately-risked, optional polish.**\nA `UnlitMaterial`\u002Femissive-only scene cannot go dark or blank from a lighting\nproblem — it has no lighting dependency to break. A scene built from\n`PhysicallyBasedMaterial` + `DirectionalLight`\u002F`PointLight` entities can\nrender solid black or fully dark if a light entity fails to attach, a shadow\nsetting misbehaves, or ambient\u002FIBL isn't configured — and that failure mode is\nmuch harder to diagnose than \"the render is dim.\" When a fully-lit,\nshadowed, particle-effects tier is the *stated* goal, still ship the unlit\nstructural tier as the safe baseline first (translucent materials, flat\ncolor, no light entities at all can still look intentional and premium — see\n`ScanConstants`-style hex-matched colors pulled from a design reference), and\ngate the lit tier as an explicit, separately-tested follow-up. This is a\ndirect trade of \"matches the mockup exactly\" against \"cannot regress to a\nworse state than before the feature existed\" — bias toward the latter for a\nfirst ship.\n\n**The 2D view stays the accessible source of truth; 3D is a sighted-only enhancement.**\nIf the feature has both a flat\u002F2D representation and a 3D one, keep them\nbacked by the **same** data-model and layout-building code (one\n`RackMapBuilder`\u002F`RackMapLayout`-equivalent used by both renderers, so they\ncan never disagree about what exists or where it sits), mark the 3D scene's\ncontainer `.accessibilityHidden` where appropriate, and never let a\ncapability (tap-to-open, quick placement, drag) exist in 3D-only. Users with\nVoiceOver, Reduce Motion, or devices where the 3D tier degrades should get a\nfully-functional experience from the 2D view alone.\n\n**Tier-honesty: when you ship less than the chosen tier, say so explicitly.**\nIf a user picks \"Full fidelity\" (lit PBR, shadows, particles) but the safe\nunlit tier is what actually ships this round, that is a legitimate\nengineering call given Gotcha above — but say so as an explicit\naccept-vs-attempt decision (\"delivered X of the 5 Full-tier items; Y\u002FZ\ndeferred because \u003Crisk>\") rather than silently reporting the lesser tier as\n\"Full re-skin done.\" Catching your own tier-downgrade before the user does is\ncheaper than them catching it on device.\n\n## Diagnostic protocol (don't skip this before picking a fix)\n\nWhen a RealityView renders wrong in only *some* mounts:\n1. List every mount (inline card, sheet, `List` row, `fullScreenCover`, etc.)\n2. Force the feature on and screenshot **each** mount independently (a debug\n   seed + forced `UserDefaults` flag + `xcrun simctl io \u003Cudid> screenshot` is\n   usually the fastest harness).\n3. Record exactly which mounts render and which don't — the pattern (e.g.\n   \"only the fullScreenCover fails\") tells you the cause; guessing from the\n   code alone before this step reliably picks the wrong hypothesis first\n   (see Gotcha 3).\n4. Only then change code, and re-screenshot the *specific* mount you fixed\n   with ≥6s settle (Gotcha 8) before calling it done.\n\n## Related skills\n- `subagent-buildverify-tool-grant-check` — if you're delegating this\n  diagnostic\u002Ffix cycle to a subagent, confirm it actually has a shell before\n  handing it a \"screenshot and verify\" acceptance test.\n- `swiftui-tabbar-swipe-nav-tradeoff` — if this 3D view sits behind a custom\n  tab bar \u002F pager, that skill's Part 3 (pushed-scroll clearance) is a\n  related-but-separate SwiftUI layout gotcha in the same feature area.\n",{"name":5,"description":7},"main","153711dd9432743d97f0b33b080ada5798ea623c","archive\u002Flearned-skills\u002Frealitykit-windowed-view-ios-gotchas","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills","https:\u002F\u002Fgithub.com\u002Fabhijitbansal","2026-11-07 12:59:51",{"source":8,"skillName":5,"commands":30,"prompt":40,"zipAvailable":41},[31,34,37],{"tool":32,"command":33},"npx","npx skills add abhijitbansal\u002Fclaude-skills --skill realitykit-windowed-view-ios-gotchas",{"tool":35,"command":36},"bunx","bunx skills add abhijitbansal\u002Fclaude-skills --skill realitykit-windowed-view-ios-gotchas",{"tool":38,"command":39},"pnpm","pnpm dlx skills add abhijitbansal\u002Fclaude-skills --skill realitykit-windowed-view-ios-gotchas","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Farchive\u002Flearned-skills\u002Frealitykit-windowed-view-ios-gotchas\u002FSKILL.md",true,[],[44,51,58,65,72,79],{"skillNo":45,"name":46,"nameZh":6,"description":47,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":48,"categories":49,"keywords":50,"publishedAt":18},"01M74XTV2V7GZM8FDBXQZZ74VX","second-wind","Orchestrate long unattended Claude Code runs across multiple repos with the wind CLI. Use when the user wants to run Claude Code overnight, resume sessions after the 5-hour usage limit, run Claude in many repos at once via tmux, or says \"set up second wind\", \"wind up\", \"overnight run\", \"resume after limit\", \"usage limit orchestrator\".","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fsecond-wind\u002Fskills\u002Fsecond-wind\u002FSKILL.md",[],[],{"skillNo":52,"name":53,"nameZh":6,"description":54,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":18},"01M74XTPGN1HDQSKGCZZX0AZPC","structured-output-adaptive-thinking-token-bloat","A Claude API call using output_config.format (json_schema structured outputs) with thinking:{type:\"adaptive\"} burns most of its output budget on thinking (observed ~21k of ~24k tokens) without improving JSON quality, making the run up to ~5x more expensive than the same call with thinking omitted — use when calling the Messages API with a json_schema output format for extraction, ranking, classification, or summarization tasks, or when a schema-constrained call's usage.output_tokens is far larger than the returned JSON.","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprompt-craft\u002Fskills\u002Fstructured-output-adaptive-thinking-token-bloat\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":18},"01M74XTKTRHAMC2JFHQ1P1E6GR","review","Apply a code-review lens to a diff, branch, or file — find correctness bugs, security issues, and quality problems, ranked by severity, with a concrete fix for each. Use when the user says \"review this\", \"review my diff\", \"check this PR\", \"look this over before I commit\", or \"is this safe\". Skip when the user wants the code written, not reviewed.","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprompt-craft\u002Fskills\u002Freview\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":18},"01M74XTGGCW7GWDDHPEMJQC7Y1","refresh","Rebuild the prompt-craft command registry and usage profile, and print a summary of installed commands and your personalized recommendations. Use when you install or update plugins and want the advisor to pick them up immediately, or say \"refresh prompt-craft\", \"rebuild the command registry\".","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprompt-craft\u002Fskills\u002Frefresh\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":18},"01M74XTCNGNR4G19P3Z95KTHQJ","refactor","Apply a refactoring lens — restructure code without changing behavior, guarded by tests that pass before and after. Use when the user says \"refactor\", \"clean this up\", \"extract this\", \"simplify this\", \"reduce duplication\", or \"make this readable\" on existing working code. Skip when the change is meant to alter behavior (that's a feature or a fix).","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprompt-craft\u002Fskills\u002Frefactor\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":18},"01M74XT9FKXN3N106G7Q3X56XR","plan","Decompose a non-trivial task into an explicit, tracked plan with goals and per-step acceptance criteria before writing code. Use when the user says \"plan this\", \"break this down\", \"what's the plan\", or asks for a multi-step feature\u002Frefactor that touches more than one file. Pairs with plan mode. Skip for single-edit changes that need no decomposition.","https:\u002F\u002Fgithub.com\u002Fabhijitbansal\u002Fclaude-skills\u002Fblob\u002Fmain\u002Fplugins\u002Fprompt-craft\u002Fskills\u002Fplan\u002FSKILL.md",[],[]]