fix: stabilize trigger callbacks to prevent missed events on Android#261
Closed
mfazekas wants to merge 1 commit into
Closed
fix: stabilize trigger callbacks to prevent missed events on Android#261mfazekas wants to merge 1 commit into
mfazekas wants to merge 1 commit into
Conversation
…230) Store onPropertyEventOverride in a ref so callback identity changes don't cause useDisposableMemo to dispose/recreate the native property during a React bailout render where effects are skipped.
Collaborator
Author
|
Closing in favor of #262 (separate trigger hook approach) |
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.
Fixes #230
Unstable
onTriggercallback references causeuseRiveTrigger(and all property hooks) to silently stop receiving events on Android after re-renders.The callback identity is now stored in a
useRef, so the native property lifecycle is decoupled from callback changes. The property is only disposed/recreated whenviewModelInstanceorpathchanges.Root cause and reproducer
Root cause
useDisposableMemodisposes the old native property and creates a new one during the render phase (via ref mutation). When the callback identity changes (e.g.onTriggerwithout React Compiler memoization),optionschanges, which triggers this dispose/create cycle.The problem: if a no-op state update (like
setError(null)when error is already null) triggers a re-render that produces identical JSX output, React bails out — it runs the component function but skips the commit and effects. SinceuseEffectis skipped, the listener is never re-subscribed to the new property.The property is orphaned — disposed old one is dead, new one has no listener. All subsequent trigger events are silently lost.
Reproducer
Actual logcat output (before fix)