Repository navigation
Conversation
useRiveList's listener cleanup called property.removeListeners(), but by then useDisposableMemo may already have disposed the property: on unmount in release builds dispose() runs synchronously before that cleanup, and on a dependency change the old property is disposed during render. Nitro only checks for a disposed object in debug builds, so in release the call dereferenced a null native object and crashed with SIGSEGV. Native dispose() already removes the listeners on both platforms, so the call is dropped. Fixes #407
…posed The operations useRiveList returns (getInstanceAt, addInstance, addInstanceAt, removeInstance, removeInstanceAt, swap) closed over the property, so one called after unmount or after the instance changed (a stale closure from a timer or an awaited continuation) called into a disposed list and crashed release builds the same way as #407. They now read the property through useDisposableMemo's liveRef, as useRiveProperty and useRiveTrigger already do: after disposal they warn and resolve without touching it, and a stale operation after an instance change acts on the current list. Also corrects the cleanup comments: only the unsubscribe function returned by addListener is safe to call there, and it doesn't throw.
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.
useRiveListcalled into its list property afteruseDisposableMemohad disposed it, which crashes release builds (Nitro only checks for disposed objects in debug). The cleanup no longer callsremoveListeners(), and the returned list operations read the property throughliveReflikeuseRivePropertydoes, so after disposal they do nothing.Verified with unit tests and an Android release build (
Issue407ListUnmountreproducer).Not changed here: iOS legacy property
dispose()never runs (a throwing protocol-extension method doesn't satisfy Nitro'sdispose()), and Android new-runtime properties skipHybridObject.dispose()because the delegateddispose()hides it.Fixes #407