Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix subscriptions for read only signals passed as props #3173

Merged
merged 9 commits into from
Nov 11, 2024

Conversation

ealmloff
Copy link
Member

@ealmloff ealmloff commented Nov 4, 2024

This PR fixes subscriptions being cleared after changing values that are converted to ReadOnlySignal at a component boundary. It also adds a fuzzing test for Rc generational box values

Fixes #3147

@ealmloff ealmloff added bug Something isn't working signals Related to the signals crate labels Nov 4, 2024
@rogusdev
Copy link
Contributor

rogusdev commented Nov 5, 2024

I can confirm that this fixed my original problem. The secondary problem that I mentioned on the bug report, however, seems to have become worse, as now I get a panic -- that does not appear to be coming from my code:

panicked at /home/chris/git/dioxus/packages/core/src/reactive_context.rs:248:14:
called `Result::unwrap()` on an `Err` value: Dropped(ValueDroppedError)

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f/<@https://REDACTED/assets/dioxus/wasm.js:600:21
logError@https://REDACTED/assets/dioxus/wasm.js:241:18
__wbg_get_imports/imports.wbg.__wbg_new_abda76e883ba8a5f@https://REDACTED/assets/dioxus/wasm.js:599:66
frontend_dioxus-438827af32741e75.wasm.console_error_panic_hook::hook::h567b39590a09c3bb@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[2292]:0x307b99
frontend_dioxus-438827af32741e75.wasm.core::ops::function::Fn::call::hfaaec962aab27ec9@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[9733]:0x466406
frontend_dioxus-438827af32741e75.wasm.std::panicking::rust_panic_with_hook::h6731baa78621a747@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[4927]:0x3f80c9
frontend_dioxus-438827af32741e75.wasm.std::panicking::begin_panic_handler::{{closure}}::hb6cd8464ed39ae71@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[6098]:0x433e05
frontend_dioxus-438827af32741e75.wasm.std::sys_common::backtrace::__rust_end_short_backtrace::hbdf3ddeb21a1e747@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[9720]:0x46639a
frontend_dioxus-438827af32741e75.wasm.rust_begin_unwind@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[7397]:0x4557ce
frontend_dioxus-438827af32741e75.wasm.core::panicking::panic_fmt::h5c7ce52813e94bcd@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[7511]:0x457360
frontend_dioxus-438827af32741e75.wasm.core::result::unwrap_failed::h4ed86702351a3017@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[6357]:0x43d801
frontend_dioxus-438827af32741e75.wasm.dioxus_core::reactive_context::ReactiveContext::subscribe::h92af43ffbe3e59c7@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[3313]:0x37e91e
frontend_dioxus-438827af32741e75.wasm.dioxus_signals::signal::Signal<T,S>::point_to::h555ff445a20fc76d@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1167]:0x23e6ee
frontend_dioxus-438827af32741e75.wasm.<frontend_dioxus::pages::folders::document_row::DocumentRowSuperPropsWithOwner as dioxus_core::properties::Properties>::memoize::h98aef720399228f6@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[750]:0x1bad7b
frontend_dioxus-438827af32741e75.wasm.<dioxus_core::any_props::VProps<F,P,M> as dioxus_core::any_props::AnyProps>::memoize::h1f3cd128e1bfe31b@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[6999]:0x44e116
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::node::<impl dioxus_core::nodes::VNode>::diff_node::h6e4782e15fcdab22@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[444]:0x102808
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::iterator::<impl dioxus_core::virtual_dom::VirtualDom>::diff_non_empty_fragment::hd95b64a70b7888c4@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[463]:0x112cc0
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::node::<impl dioxus_core::nodes::VNode>::diff_node::h6e4782e15fcdab22@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[444]:0x102a34
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::iterator::<impl dioxus_core::virtual_dom::VirtualDom>::diff_non_empty_fragment::hd95b64a70b7888c4@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[463]:0x112cc0
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::node::<impl dioxus_core::nodes::VNode>::diff_node::h6e4782e15fcdab22@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[444]:0x102a34
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::iterator::<impl dioxus_core::virtual_dom::VirtualDom>::diff_non_empty_fragment::hd95b64a70b7888c4@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[463]:0x112cc0
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::node::<impl dioxus_core::nodes::VNode>::diff_node::h6e4782e15fcdab22@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[444]:0x102a34
frontend_dioxus-438827af32741e75.wasm.dioxus_core::runtime::Runtime::with_scope_on_stack::hb5864699da8a0fae@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1655]:0x2a6ac7
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::component::<impl dioxus_core::virtual_dom::VirtualDom>::run_and_diff_scope::he1d616b238296fae@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1032]:0x21c24c
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::node::<impl dioxus_core::nodes::VNode>::diff_node::h6e4782e15fcdab22@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[444]:0x102813
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::iterator::<impl dioxus_core::virtual_dom::VirtualDom>::diff_non_empty_fragment::hd95b64a70b7888c4@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[463]:0x112cc0
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::node::<impl dioxus_core::nodes::VNode>::diff_node::h6e4782e15fcdab22@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[444]:0x102a34
frontend_dioxus-438827af32741e75.wasm.dioxus_core::runtime::Runtime::with_scope_on_stack::hb5864699da8a0fae@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1655]:0x2a6ac7
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::component::<impl dioxus_core::virtual_dom::VirtualDom>::run_and_diff_scope::he1d616b238296fae@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1032]:0x21c24c
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::node::<impl dioxus_core::nodes::VNode>::diff_node::h6e4782e15fcdab22@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[444]:0x102813
frontend_dioxus-438827af32741e75.wasm.dioxus_core::runtime::Runtime::with_scope_on_stack::hb5864699da8a0fae@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1655]:0x2a6ac7
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::component::<impl dioxus_core::virtual_dom::VirtualDom>::run_and_diff_scope::he1d616b238296fae@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1032]:0x21c24c
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::node::<impl dioxus_core::nodes::VNode>::diff_node::h6e4782e15fcdab22@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[444]:0x102813
frontend_dioxus-438827af32741e75.wasm.dioxus_core::runtime::Runtime::with_scope_on_stack::hb5864699da8a0fae@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1655]:0x2a6ac7
frontend_dioxus-438827af32741e75.wasm.dioxus_core::diff::component::<impl dioxus_core::virtual_dom::VirtualDom>::run_and_diff_scope::he1d616b238296fae@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1032]:0x21c24c
frontend_dioxus-438827af32741e75.wasm.dioxus_core::virtual_dom::VirtualDom::render_immediate::h56e2554653230e95@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[2201]:0x2fba13
frontend_dioxus-438827af32741e75.wasm.dioxus_web::launch::launch_virtual_dom::{{closure}}::hbfecae087facf0d5@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1748]:0x2b676e
frontend_dioxus-438827af32741e75.wasm.wasm_bindgen_futures::queue::QueueState::run_all::hccd72c989afee737@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[2770]:0x344319
frontend_dioxus-438827af32741e75.wasm.wasm_bindgen_futures::queue::Queue::new::{{closure}}::h2d4e0d8b1d97e6e4@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[8071]:0x45da04
frontend_dioxus-438827af32741e75.wasm.<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hd7cbc4e4c016252e@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[8070]:0x45d9f6
__wbg_adapter_62@https://REDACTED/assets/dioxus/wasm.js:292:10
real@https://REDACTED/assets/dioxus/wasm.js:224:20
VoidFunction*__wbg_get_imports/imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4/<@https://REDACTED/assets/dioxus/wasm.js:784:23
logError@https://REDACTED/assets/dioxus/wasm.js:241:18
__wbg_get_imports/imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4@https://REDACTED/assets/dioxus/wasm.js:783:77
frontend_dioxus-438827af32741e75.wasm.wasm_bindgen_futures::queue::Queue::schedule_task::h5e237e4cbb8c5a54@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[5806]:0x426a4b
frontend_dioxus-438827af32741e75.wasm.wasm_bindgen_futures::task::singlethread::Task::into_raw_waker::raw_wake::h0790213682446051@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[6127]:0x43508c
frontend_dioxus-438827af32741e75.wasm.futures_core::task::__internal::atomic_waker::AtomicWaker::wake::h02b3c8dc3ec6e1a6@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[7302]:0x453f00
frontend_dioxus-438827af32741e75.wasm.<dioxus_core::tasks::LocalTaskHandle as futures_task::arc_wake::ArcWake>::wake_by_ref::h3f1af0f8e8a29bea@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[5625]:0x41d924
frontend_dioxus-438827af32741e75.wasm.futures_task::waker::wake_arc_raw::h72b2c322a6e2fa3f@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[6932]:0x44ca22
frontend_dioxus-438827af32741e75.wasm.<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::finish::hce432aaf7319c469@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[4551]:0x3e078b
frontend_dioxus-438827af32741e75.wasm.<T as wasm_bindgen::closure::WasmClosureFnOnce<A,R>>::into_fn_mut::{{closure}}::ha914fd6609e98f2c@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[6879]:0x44b71f
frontend_dioxus-438827af32741e75.wasm.<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hd7cbc4e4c016252e@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[8070]:0x45d9f6
__wbg_adapter_62@https://REDACTED/assets/dioxus/wasm.js:292:10
real@https://REDACTED/assets/dioxus/wasm.js:224:20
promise callback*__wbg_get_imports/imports.wbg.__wbg_then_876bb3c633745cc6/<@https://REDACTED/assets/dioxus/wasm.js:1970:37
logError@https://REDACTED/assets/dioxus/wasm.js:241:18
__wbg_get_imports/imports.wbg.__wbg_then_876bb3c633745cc6@https://REDACTED/assets/dioxus/wasm.js:1969:67
frontend_dioxus-438827af32741e75.wasm.js_sys::Promise::then2::h4fa9bc7d93388b07@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[8365]:0x45f67f
frontend_dioxus-438827af32741e75.wasm.<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::h6ddd1b48de7e05a3@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[2096]:0x2ec551
frontend_dioxus-438827af32741e75.wasm.frontend_dioxus::pages::auth::utils::send_request_parse_json_inner::{{closure}}::h8c5c501afe88d885@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[362]:0xa3e7b
frontend_dioxus-438827af32741e75.wasm.frontend_dioxus::pages::auth::utils::send_request_parse_json::{{closure}}::h192d1c7d0545761c@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[804]:0x1d10f3
frontend_dioxus-438827af32741e75.wasm.dioxus_core::tasks::<impl dioxus_core::runtime::Runtime>::handle_task_wakeup::h7a8f9d72acb0d9b7@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1677]:0x2aa5db
frontend_dioxus-438827af32741e75.wasm.dioxus_core::virtual_dom::VirtualDom::poll_tasks::h39c0c278e77f801c@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[456]:0x10ce92
frontend_dioxus-438827af32741e75.wasm.dioxus_core::virtual_dom::VirtualDom::process_events::h304a266b578cd467@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1740]:0x2b5013
frontend_dioxus-438827af32741e75.wasm.<futures_util::future::future::fuse::Fuse<Fut> as core::future::future::Future>::poll::hf0ec6a50d4add2cf@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[764]:0x1c0e4b
frontend_dioxus-438827af32741e75.wasm.dioxus_web::run::{{closure}}::{{closure}}::{{closure}}::h2ee3e8c14eeef7f9@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[7752]:0x45a7c1
frontend_dioxus-438827af32741e75.wasm.<futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll::hf6e15e341f4efd28@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[4794]:0x3f046a
frontend_dioxus-438827af32741e75.wasm.dioxus_web::launch::launch_virtual_dom::{{closure}}::hbfecae087facf0d5@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[1748]:0x2b674c
frontend_dioxus-438827af32741e75.wasm.wasm_bindgen_futures::queue::QueueState::run_all::hccd72c989afee737@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[2770]:0x344319
frontend_dioxus-438827af32741e75.wasm.wasm_bindgen_futures::queue::Queue::new::{{closure}}::h2d4e0d8b1d97e6e4@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[8071]:0x45da04
frontend_dioxus-438827af32741e75.wasm.<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hd7cbc4e4c016252e@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[8070]:0x45d9f6
__wbg_adapter_62@https://REDACTED/assets/dioxus/wasm.js:292:10
real@https://REDACTED/assets/dioxus/wasm.js:224:20
VoidFunction*__wbg_get_imports/imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4/<@https://REDACTED/assets/dioxus/wasm.js:784:23
logError@https://REDACTED/assets/dioxus/wasm.js:241:18
__wbg_get_imports/imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4@https://REDACTED/assets/dioxus/wasm.js:783:77
frontend_dioxus-438827af32741e75.wasm.wasm_bindgen_futures::queue::Queue::schedule_task::h5e237e4cbb8c5a54@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[5806]:0x426a4b
frontend_dioxus-438827af32741e75.wasm.wasm_bindgen_futures::task::singlethread::Task::into_raw_waker::raw_wake::h0790213682446051@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[6127]:0x43508c
frontend_dioxus-438827af32741e75.wasm.futures_core::task::__internal::atomic_waker::AtomicWaker::wake::h02b3c8dc3ec6e1a6@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[7302]:0x453f00
frontend_dioxus-438827af32741e75.wasm.<dioxus_core::tasks::LocalTaskHandle as futures_task::arc_wake::ArcWake>::wake_by_ref::h3f1af0f8e8a29bea@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[5625]:0x41d924
frontend_dioxus-438827af32741e75.wasm.futures_task::waker::wake_arc_raw::h72b2c322a6e2fa3f@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[6932]:0x44ca22
frontend_dioxus-438827af32741e75.wasm.<wasm_bindgen_futures::JsFuture as core::convert::From<js_sys::Promise>>::from::finish::hce432aaf7319c469@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[4551]:0x3e078b
frontend_dioxus-438827af32741e75.wasm.<T as wasm_bindgen::closure::WasmClosureFnOnce<A,R>>::into_fn_mut::{{closure}}::ha914fd6609e98f2c@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[6879]:0x44b71f
frontend_dioxus-438827af32741e75.wasm.<dyn core::ops::function::FnMut<(A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::hd7cbc4e4c016252e@https://REDACTED/assets/dioxus/wasm_bg.wasm:wasm-function[8070]:0x45d9f6


wasm.js:616:21

@ealmloff
Copy link
Member Author

ealmloff commented Nov 9, 2024

I can confirm that this fixed my original problem. The secondary problem that I mentioned on the bug report, however, seems to have become worse, as now I get a panic -- that does not appear to be coming from my code:

panicked at /home/chris/git/dioxus/packages/core/src/reactive_context.rs:248:14:
called `Result::unwrap()` on an `Err` value: Dropped(ValueDroppedError)

@rogusdev without any way to reproduce the issue, there isn't much I can do to debug the second issue. Can you create a reproduction?

@ealmloff ealmloff closed this Nov 9, 2024
@ealmloff ealmloff reopened this Nov 9, 2024
@rogusdev
Copy link
Contributor

rogusdev commented Nov 9, 2024

I was hoping the stack trace would pop a lightbulb for you. If not, I support merging this as it is, because it is simple enough and does solve one problem. And then I will find a repro for the other thing.

Thanks

@ealmloff
Copy link
Member Author

ealmloff commented Nov 9, 2024

I misread the backtrace. We can just ignore subscriptions to dropped reactive contexts. I think the panic should be fixed, but I'm still not sure what is causing the missing subscriptions

@rogusdev
Copy link
Contributor

rogusdev commented Nov 9, 2024

Your latest does indeed fix the panic and now I can use this! I may have found a repro for a reactive context dropped error, which may or may not be the same / related error. I will create that as a separate issue tho, as the original concerns I had seem to be resolved with these changes and would highly encourage them to get merged.

@rogusdev
Copy link
Contributor

rogusdev commented Nov 9, 2024

All that said, the repro app I put in the issue does still give this warning (twice, immediately) when following the steps (click on 1 then click on 2) -- tho at least it now displays properly! Maybe that might help you investigate this better?

WARN /home/chris/git/dioxus/packages/signals/src/warnings.rs:62 Write on signal at /home/chris/git/dioxus/packages/signals/src/read_only_signal.rs:55:24 happened while a component was running. Writing to signals during a render can cause infinite rerenders when you read the same signal in the component. Consider writing to the signal in an effect, future, or event handler if possible

@jkelleyrtp jkelleyrtp merged commit 45a1147 into DioxusLabs:main Nov 11, 2024
@ealmloff ealmloff deleted the fuzz-rc branch November 11, 2024 03:03
@rogusdev
Copy link
Contributor

rogusdev commented Nov 11, 2024

I am good for this getting merged but @ealmloff or @jkelleyrtp what should we do about that warning I'm getting now? The repro on the issue triggers it completely consistently. Would you like me to create a new issue for it? Created an issue for this warning, plus the panic I also saw that may or may not be related: #3196

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.

Bug with nested Link?...
3 participants