Skip to content

Fix crash on rotation while drafting a post (#2461)#2473

Open
meet4731 wants to merge 1 commit into
Dimillian:mainfrom
meet4731:fix-rotation-crash
Open

Fix crash on rotation while drafting a post (#2461)#2473
meet4731 wants to merge 1 commit into
Dimillian:mainfrom
meet4731:fix-rotation-crash

Conversation

@meet4731

@meet4731 meet4731 commented Jul 8, 2026

Copy link
Copy Markdown

Fixes #2461 — the app crashes if you rotate the device while the post composer is open.

Digging into it (and matching the AttributeGraph cycle log pylapp posted on the issue), the crash is a SwiftUI AttributeGraph cycle: when a focused UITextView is in the compose sheet and the interface rotates, the update loop cycles and the watchdog kills the app. The existing device-orientation observer doesn't help here because it only fires after the rotation has already happened, by which point the cycle's formed.

The fix is to host the editor's text view in a small TextViewController (UIViewControllerRepresentable) so it gets a viewWillTransition hook. That fires just before the rotation animation starts, so resigning first responder there drops the keyboard in time to stop the cycle forming in the first place. I've left the orientation observer in as a backstop for the post-rotation case.

One extra change: I had to qualify SwiftSoup.Document in HTMLString.swift — it was hitting an ambiguous type-lookup error building on the current toolchain.

Tested by reproducing the crash (open composer, rotate) and confirming it's gone. Editor sizing and behaviour are unchanged; the only difference is focus now starts on tap rather than automatically.

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.

Bug: screen rotation while drafting crashes app

2 participants