Skip to content

fix(ios): tall code blocks with long lines no longer draw an empty pane - #15

Open
Muzammil-Bit wants to merge 1 commit into
pingdotgg:fork/t3-mobilefrom
Muzammil-Bit:fix/ios-tall-code-block-blank
Open

Muzammil-Bit wants to merge 1 commit into
pingdotgg:fork/t3-mobilefrom
Muzammil-Bit:fix/ios-tall-code-block-blank

Conversation

@Muzammil-Bit

@Muzammil-Bit Muzammil-Bit commented Nov 9, 2026 •

Copy link
Copy Markdown

On iOS, a tall code block with long lines showed its header and reserved its full height, but the code pane stayed empty. The text only appeared after tapping wrap. Reported in pingdotgg/t3code#32928.

The pane drew its code through drawRect: on a single view sized to the whole block: the full code width by the full height. A JSON block of a few hundred lines with long strings needs a backing store of more than a gigabyte at 3x, so iOS never allocates one and the pane stays blank. Wrapping fixed it only because it narrowed the pane to the screen width. It was not a missed redraw.

The content view keeps its TextKit stack but no longer draws on iOS. A canvas child draws for it:

  • Panes under 2048×2048 pixels use a plain drawRect: canvas, so ordinary blocks still draw in their first frame.
  • Larger panes use a CATiledLayer canvas (1024 px tiles, no fade), which only allocates and draws the tiles on screen.
  • Tiles draw on background threads, so the TextKit stack, the text origin and drawing share a lock.

macOS keeps drawing in the view itself.

Verified on an iPhone 15 simulator (iOS 26.5) in the T3 Code dev client, with a 543-line JSON block whose longest line is 347 characters. Before the change the pane is blank until wrap is tapped. After it, the code shows on open, scrolls horizontally, and wraps and unwraps. A 403-line narrow block and a small highlighted TypeScript block also render as before. Recordings are on the T3 Code PR that vendors this commit.

Note

Fix empty drawing pane for tall iOS code blocks with long lines

  • iOS code blocks now render through a child canvas view that forwards drawRect: to ENRMCodeBlockContentView.drawCodeInRect:.
  • layoutSubviews: estimates the backing pixel area and picks a tiled canvas (ENRMCodeBlockTiledCanvasView, 1024x1024-point tiles, no fade) when it exceeds 2048x2048 pixels, otherwise a standard canvas.
  • All TextKit mutations (setAttributedCode, setTextOrigin, setWrapWidth, usedWidth) and drawing are serialized with @synchronized(self).
  • macOS gets a drawRect: that delegates to drawCodeInRect:.
  • Risk: check the tile-size and 2048-pixel threshold in ENRMCodeBlockContainerView.m — blocks near the threshold may switch canvas classes between layouts.

Macroscope summarized 0dc7ed8.

The code pane drew through drawRect: on one view sized to the whole block,
so a tall block with long lines needed a backing store larger than iOS
would allocate and showed an empty pane until wrapping narrowed it. The
pane now draws through a canvas child that switches to a CATiledLayer
once it is too big for one store; smaller blocks still draw in their
first frame.

Fixes pingdotgg/t3code#32928
@coderabbitai

coderabbitai Bot commented Nov 9, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6f1de80e-d20c-4c6a-b39a-9c1a23690e81
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

1 participant