labs
한국어 hello@taklabs.dev

Why the stage turned magenta on iOS 18: 576.33 points

When the viewer stage became 576.33pt tall, SCNView on iOS 18 stopped drawing anything. I round the stage up to whole points and clip the overflow, and any camera change made in the viewer is now undone when the viewer closes.

What broke?

I opened the full-size viewer ("크게 보기") in debegi on an iPhone 13 Pro running iOS 18.7, and the stage was solid magenta: no character, no floor, just a flat sheet of colour. I had started this session to put a build on a real device and look over its screens, so my first question was whether the install had even worked.

The bug came from the PR just before this one, #16. That PR moved the viewer controls below the stage, so the stage now got "whatever height is left on the screen." On a 3× phone, that height can land on a 1/3-point boundary. On the 13 Pro it came out to 390 × 576.33pt.

Why didn't the simulator show it?

iOS 26 and 27 draw the scene at that size without trouble. I normally run tests on an iOS 27 simulator, so every test passed and the bug never showed up. Of everything I had looked at, only iOS 18 broke.

How did I narrow down the cause?

I started with the device log. The viewer's SCNView had bounds of 390 × 576.33 and a drawable of 1170 × 1728, while a snapshot of the same view measured 1170 × 1729, so the two sizes were off by 1px. On the same screen, the Today card (362 × 270) and the debug stage (390 × 508) had whole-number sizes, and both rendered normally.

My first guess was an odd pixel count. To test it, I set the debug stage to 393 × 533.33pt on an iOS 18.3 simulator and added a switch to turn the correction on and off within a single build. With the correction off, the whole stage was black (average RGB 0,0,0). With it on, the character and the floor appeared. The device showed magenta where the simulator showed black, but the same correction cleared both, so I treated them as one defect. I didn't check why the colors differ. A height of 535pt also drew correctly, even though that works out to an odd 1605px, so odd pixels weren't the problem. Fractional points were.

PR 16 moves controls below the stage Stage gets the leftover height 3× phone: 390 × 576.33pt iOS 18 SCNView draws nothing StageHost rounds up to whole points Whole pixels, overflow clipped Character and floor visible

What changed?

StageView no longer places the SCNView directly. The view now sits inside a StageHost, which rounds the SceneKit view's size up to whole points and clips whatever extends past the edge. Whole points times the screen scale always gives whole pixels. I moved the accessibility id stage and the background colour to the host. Gestures and render settings are unchanged.

I also added a unit test, testTheSceneViewIsLaidOutInWholePoints, which fails if the rounding is removed. Its failure message points straight at the cause:

("(0.0, 0.0, 390.0, 576.3333333333334)") is not equal to …

The fix isn't free. The stage is drawn up to just under 1pt larger and then clipped, and the centre of the picture can shift by up to 0.5pt. I decided that was acceptable. Every stage in the app (Today, detail, viewer, onboarding and debug) goes through StageHost, so the change touches the whole app, but it's easy to back out.

Why does the camera get reset?

While trying the fixed build on the phone, I noticed a second problem.

If I change the camera angle in the viewer and close it, the home screen keeps that angle too. It should go back when the viewer closes.

If you picked a camera angle in the viewer, it stuck to the screen underneath after the viewer closed. The Today screen has no angle buttons, so the only way to change it back was to open the viewer again.

I decided a camera change made in the viewer should stay in the viewer. StageController.cameraView now reads and writes angle, rotation, tilt and zoom as one value. The viewer saves that value when it opens and restores it when it closes. The speed picker is still shared by both screens, as before. So if you open the viewer from the detail screen and change the angle, closing the viewer brings back the detail screen's angle, and changing the angle on the detail screen means using its own buttons.

The UI test picks the top angle ("위") in the viewer, closes it, and checks that the detail screen still shows the front angle ("정면"). If the restore is removed, the test fails with an angle picked in the viewer stays in the viewer.

How did I check it on the device?

The app's offscreen snapshots looked correct even while the screen was broken, so they couldn't settle anything. At PR time the phone was off the cable, so I couldn't see its screen. Later I opened the viewer myself on the 13 Pro with the fixed build, and the stage showed the character and the floor. The 1px-short drawable is still only a number I read in the log; I don't know why that shortfall makes SceneKit leave the whole view blank.

On the final commit, 210 unit tests and 12 UI tests passed on an iOS 27 simulator. The work took one session, added 90 lines and removed 6, and cost about $2.71. As long as I test on a single simulator version, bugs like this one only turn up on a real device. If your screens use SceneKit, keeping an older iOS simulator in the test run is worth it.

Viewer opens: save cameraView Angle, rotation, tilt, zoom change in the viewer Viewer closes: restore the saved value Screen underneath keeps its angle

Build stats

ModelInputOutputCache readCache writeUSD
claude-fable-5-26018,9647,490,09228,312$2.71
Total6018,9647,490,09228,312$2.71
claude-fable-5-27,537,428
Tokens by model
land1
Skill calls

Counted from 1 session transcript at 2026-11-15T01:33Z (PR #20, sessions 2026-11-14 to 2026-11-15). Tokens include subagents; USD is list price. Code: +90 / −6 lines.