Skip to content

Drop Weak<WaitableNativeActivityState> in on_destroy#237

Merged
rib merged 1 commit intomainfrom
rib/pr/free-weak-ref-native-activity-state
Mar 19, 2026
Merged

Drop Weak<WaitableNativeActivityState> in on_destroy#237
rib merged 1 commit intomainfrom
rib/pr/free-weak-ref-native-activity-state

Conversation

@rib
Copy link
Copy Markdown
Member

@rib rib commented Mar 19, 2026

When we know we're done with the Weak reference that is associated with the NativeActivity callbacks we make sure to drop the Weak reference so that the underlying allocation for the WaitableNativeActivityState can be freed.

This also updates try_with_waitable_activity_ref to be more careful about converting the Weak ref back into a raw pointer before calling the handler, just in case the handler triggers a panic and unwinds (where we wouldn't want to lose/Drop our weak ref).

When we know we're done with the `Weak` reference that is associated with
the `NativeActivity` callbacks we make sure to drop the `Weak` reference
so that the underlying allocation for the `WaitableNativeActivityState`
can be freed.

This also updates `try_with_waitable_activity_ref` to be more careful
about converting the `Weak` ref back into a raw pointer _before_ calling
the handler, just in case the handler triggers a panic and unwinds
(where we wouldn't want to lose/Drop our weak ref).
@rib rib merged commit b042af6 into main Mar 19, 2026
7 checks passed
@rib rib deleted the rib/pr/free-weak-ref-native-activity-state branch March 19, 2026 00:48
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