Repository navigation
fix(ios): tall code blocks with long lines no longer draw an empty pane - #15
Open
Muzammil-Bit wants to merge 1 commit into
Open
Muzammil-Bit wants to merge 1 commit into
Muzammil-Bit wants to merge 1 commit into
Conversation
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
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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.
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:
drawRect:canvas, so ordinary blocks still draw in their first frame.CATiledLayercanvas (1024 px tiles, no fade), which only allocates and draws the tiles on screen.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
drawRect:toENRMCodeBlockContentView.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.setAttributedCode,setTextOrigin,setWrapWidth,usedWidth) and drawing are serialized with@synchronized(self).drawRect:that delegates todrawCodeInRect:.Macroscope summarized 0dc7ed8.