Skip to content

Fix unnecessary reruns after read signal coercion#5475

Open
ealmloff wants to merge 29 commits into
DioxusLabs:mainfrom
ealmloff:fix-leaky-readsignal-subscriptions
Open

Fix unnecessary reruns after read signal coercion#5475
ealmloff wants to merge 29 commits into
DioxusLabs:mainfrom
ealmloff:fix-leaky-readsignal-subscriptions

Conversation

@ealmloff
Copy link
Copy Markdown
Member

@ealmloff ealmloff commented Apr 9, 2026

Instead of moving and marking all reactive contexts as dirty when the source of the ReadSignal changes, this pr limits the scope to just the contexts that where explicitly used with the boxed version

image image

Fixes #5474

@jkelleyrtp jkelleyrtp changed the title Fix unnessicary reruns after read signal coercion Fix unnecessary reruns after read signal coercion Apr 14, 2026
ealmloff added 23 commits May 11, 2026 16:33
Move the wrapped readable, the wrapper-level subscriber list, and the
forwarding reactive context into one shared `ReadSignalInner` allocation
so creating a wrapper costs the same one generational-box reference as a
bare `Signal`. This keeps `test_for_memory_leaks` passing on the
props-macro coercion path that constructs a fresh `ReadSignal` per
render: peak memory stays flat across 10000 iterations.

`point_to` moves the wrapped readable out of `other.inner` via
`Option::take` and releases `other.inner` immediately, instead of using
`CopyValue::point_to` and leaking the new wrapper's state. Subscribers
and the forwarding context are lazily initialized so wrappers that are
never read pay nothing extra; the forwarding callback captures the
`Subscribers` handle directly so it remains `Send + Sync` regardless of
the wrapper's storage type.

Fixes clippy warnings in the new tests.
# Conflicts:
#	packages/signals/src/boxed.rs
#	packages/signals/tests/memo.rs
@ealmloff ealmloff marked this pull request as ready for review May 13, 2026 14:38
@ealmloff ealmloff requested a review from a team as a code owner May 13, 2026 14:38
@ealmloff ealmloff added bug Something isn't working signals Related to the signals crate labels May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working signals Related to the signals crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ReadSignal coercion can cause extra reruns

1 participant