You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 11, 2024. It is now read-only.
We introduced synchronous becomeFirstResponder to fix keyboard tearing. However, in this one case, it is causing an AttributeGraph cycle. The cycle does seem to be shortcutted by our early-exit check within textViewDidBeginEditing ("View updating. Skipping.") so that's good.
Workaround... I'm at my wit's end. I've tried a bunch of stuff with MarkupViewRepresentable, none of which worked. Even refraining from setting the focus binding in the delegate doesn't solve it. If I call resignFirstResponder (or sometimes becomeFirstResponder) synchronously in updateUIView then I hit this case.
So it seems the only thing for it is to call it async, which means we need to time animations to when focus actually finishes, to prevent keyboard tearing. This means treating editor focus binding as "what I wish focus was", and not "what focus actually is".
Perhaps we can introduce callbacks, or have two bindings, one for desiredFocus and another for currentFocus?
Update: it looks like this may not work out. Unfortunately, it seems that becomeFirstResponder MUST be called synchronously to avoid animation jank with NavigationView sliding panel animation. This is because the view doesn't even get created until the animation is started (it's in a closure).
It may be work accepting this single attributegraph cycle warning for now. I'm not sure there is any workaround.
Update: another idea. Maybe we call first responder methods synchronously, but only in makeUIView?
Update 2: this seems to work. It's not a complete fix, but it at least solves for the problem of wanting to create a view and immediately focus it.
@natanel has asked:
Can you explain the AttributeGraph that comes up while debugging sometimes?
Curt (Apple)
I’m afraid we can’t discuss implementation details, but be sure to check out the talk “Demystify SwiftUI” for the details of the dependency graph. https://developer.apple.com/wwdc21/10022 It’s a great talk and should help provide intuition on how things work.
Fixes#253
Follow-up to #251.
Fixes keyboard tearing for NavigationView animation while still allowing
us to call first responder change methods async in updateUIView, fixing
attribute graph cycle warnings.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Issue introduced by #251.
We introduced synchronous
becomeFirstResponder
to fix keyboard tearing. However, in this one case, it is causing an AttributeGraph cycle. The cycle does seem to be shortcutted by our early-exit check withintextViewDidBeginEditing
("View updating. Skipping.") so that's good.Workaround... I'm at my wit's end. I've tried a bunch of stuff with MarkupViewRepresentable, none of which worked. Even refraining from setting the focus binding in the delegate doesn't solve it. If I call
resignFirstResponder
(or sometimesbecomeFirstResponder
) synchronously inupdateUIView
then I hit this case.So it seems the only thing for it is to call it async, which means we need to time animations to when focus actually finishes, to prevent keyboard tearing. This means treating editor focus binding as "what I wish focus was", and not "what focus actually is".
Perhaps we can introduce callbacks, or have two bindings, one for
desiredFocus
and another forcurrentFocus
?Update: it looks like this may not work out. Unfortunately, it seems that becomeFirstResponder MUST be called synchronously to avoid animation jank with NavigationView sliding panel animation. This is because the view doesn't even get created until the animation is started (it's in a closure).
It may be work accepting this single attributegraph cycle warning for now. I'm not sure there is any workaround.
Update: another idea. Maybe we call first responder methods synchronously, but only in makeUIView?
Update 2: this seems to work. It's not a complete fix, but it at least solves for the problem of wanting to create a view and immediately focus it.
Steps to reproduce
Log:
The text was updated successfully, but these errors were encountered: