Skip to content

fix: resolve font height compression when keyboard appears#2

Merged
e16tae merged 1 commit intomainfrom
fix/viewport-keyboard-compression
Mar 10, 2026
Merged

fix: resolve font height compression when keyboard appears#2
e16tae merged 1 commit intomainfrom
fix/viewport-keyboard-compression

Conversation

@e16tae
Copy link
Owner

@e16tae e16tae commented Mar 10, 2026

Summary

  • Keyboard appearance caused font height to visually compress due to view.bounds / drawable size timing mismatch during animated resize
  • Cache viewport from drawableSizeWillChange (drawable-derived, not bounds) to guarantee viewport matches rendering target
  • Add missing setNeedsDisplay() call to trigger immediate redraw on drawable resize

Root Cause

draw() read view.bounds for the shader viewport, but during keyboard animation, bounds can lag behind the already-resized drawable. The stale (larger) viewport caused the vertex shader to map content into a smaller drawable, compressing only the vertical axis (keyboard only changes height).

Test plan

  • Build succeeds
  • Tested on physical device (iPhone 15 Plus, iOS 26.3.1)
  • Keyboard appear/dismiss — font height stays consistent
  • Device rotation — normal rendering
  • App cold start — first frame renders correctly

🤖 Generated with Claude Code

The Metal renderer used view.bounds for viewport calculation in draw(),
but bounds can lag behind the drawable size during animated resizes
(e.g. keyboard appearance). This caused the vertex shader to map content
using stale dimensions, compressing font height vertically.

Cache viewport size from drawableSizeWillChange (derived from drawable)
and add the missing setNeedsDisplay() call to trigger immediate redraw
on resize — matching Apple's standard Metal on-demand rendering pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@e16tae e16tae merged commit 55b8c83 into main Mar 10, 2026
1 check failed
@e16tae e16tae deleted the fix/viewport-keyboard-compression branch March 10, 2026 00:52
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