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

"thread '<unnamed>' panicked at 'called Option::unwrap() on a None value'," while setting state (Global/local/ref)) #626

Closed
3 tasks
aliTanveerAnalog opened this issue Nov 21, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@aliTanveerAnalog
Copy link

aliTanveerAnalog commented Nov 21, 2022

Problem

  • There is a rust compiler panic attack "thread '' panicked at 'called Option::unwrap() on a None value'" while setting a global/local or ref state in component.
  • This problem raised due to using the html input component.
  • Commenting or removing the input component code resolves the issue.

Steps To Reproduce

Expected behavior

  • The state should be set and component should be re-rendered by updating the state without rust panic.

Screenshots
Screenshot 2022-11-21 at 11 09 10 PM
Screenshot 2022-11-21 at 11 09 29 PM

Environment:

  • Dioxus version: [e.g. v0.17, master]
  • Rust version: [e.g. 1.43.0, nightly]
  • OS info: [e.g. MacOS]
  • App platform: [e.g. web, desktop]

BACKTRACE LOGS

thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/core/src/template.rs:477:34
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   2: core::panicking::panic
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:48:5
   3: core::option::Option<T>::unwrap
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/option.rs:775:21
   4: dioxus_core::template::VTemplateRef::get_node_id
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/core/src/template.rs:477:9
   5: dioxus_core::diff::DiffState::diff_template_ref_nodes::set_attribute
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/core/src/diff.rs:679:31
   6: core::ops::function::FnMut::call_mut
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ops/function.rs:164:5
   7: dioxus_core::template::Template::with_node
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/core/src/template.rs:637:36
   8: dioxus_core::diff::DiffState::diff_template_ref_nodes
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/core/src/diff.rs:769:13
   9: dioxus_core::diff::DiffState::diff_node
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/core/src/diff.rs:168:17
  10: dioxus_core::diff::DiffState::diff_scope
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/core/src/diff.rs:132:13
  11: dioxus_core::virtual_dom::VirtualDom::work_with_deadline
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/core/src/virtual_dom.rs:500:21
  12: dioxus_desktop::controller::DesktopController::new_on_tokio::{{closure}}::{{closure}}
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/desktop/src/controller.rs:70:32
  13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/future/mod.rs:91:19
  14: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/tokio-1.22.0/src/runtime/park.rs:272:63
  15: tokio::runtime::coop::with_budget
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/tokio-1.22.0/src/runtime/coop.rs:102:5
  16: tokio::runtime::coop::budget
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/tokio-1.22.0/src/runtime/coop.rs:68:5
  17: tokio::runtime::park::CachedParkThread::block_on
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/tokio-1.22.0/src/runtime/park.rs:272:31
  18: tokio::runtime::context::BlockingRegionGuard::block_on
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/tokio-1.22.0/src/runtime/context.rs:255:13
  19: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/tokio-1.22.0/src/runtime/scheduler/multi_thread/mod.rs:66:9
  20: tokio::runtime::runtime::Runtime::block_on
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/tokio-1.22.0/src/runtime/runtime.rs:281:45
  21: dioxus_desktop::controller::DesktopController::new_on_tokio::{{closure}}
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/desktop/src/controller.rs:45:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: TrySendError { kind: Disconnected }', /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/desktop/src/lib.rs:149:87
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/result.rs:1814:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/result.rs:1107:23
   4: dioxus_desktop::launch_with_props::{{closure}}::{{closure}}::{{closure}}
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/desktop/src/lib.rs:149:37
   5: core::option::Option<T>::map
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/option.rs:929:29
   6: dioxus_desktop::launch_with_props::{{closure}}::{{closure}}
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/desktop/src/lib.rs:144:25
   7: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/alloc/src/boxed.rs:1949:9
   8: wry::webview::wkwebview::InnerWebView::new::did_receive
             at /Users/alitanveer/.cargo/git/checkouts/wry-39db0ea36a21c591/8210afa/src/webview/wkwebview/mod.rs:101:11
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>
  16: <unknown>
  17: <unknown>
  18: <unknown>
  19: <unknown>
  20: <unknown>
  21: <unknown>
  22: <unknown>
  23: <unknown>
  24: <unknown>
  25: <unknown>
  26: <unknown>
  27: <unknown>
  28: <unknown>
  29: <unknown>
  30: <() as objc::message::MessageArguments>::invoke
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/objc-0.2.7/src/message/mod.rs:128:17
  31: objc::message::platform::send_unverified::{{closure}}
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/objc-0.2.7/src/message/apple/mod.rs:27:9
  32: objc_exception::try::{{closure}}
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/objc_exception-0.1.2/src/lib.rs:68:31
  33: objc_exception::try_no_ret::try_objc_execute_closure
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/objc_exception-0.1.2/src/lib.rs:34:9
  34: RustObjCExceptionTryCatch
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/objc_exception-0.1.2/extern/exception.m:10:9
  35: objc_exception::try_no_ret
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/objc_exception-0.1.2/src/lib.rs:44:19
  36: objc_exception::try
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/objc_exception-0.1.2/src/lib.rs:67:9
  37: objc::exception::try
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/objc-0.2.7/src/exception.rs:8:5
  38: objc::message::platform::send_unverified
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/objc-0.2.7/src/message/apple/mod.rs:26:5
  39: objc::message::send_message
             at /Users/alitanveer/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/objc-0.2.7/src/message/mod.rs:178:5
  40: tao::platform_impl::platform::event_loop::EventLoop<T>::run_return
             at /Users/alitanveer/.cargo/git/checkouts/tao-5e7ba162f074538b/d72b1e1/src/platform_impl/macos/event_loop.rs:188:16
  41: tao::platform_impl::platform::event_loop::EventLoop<T>::run
             at /Users/alitanveer/.cargo/git/checkouts/tao-5e7ba162f074538b/d72b1e1/src/platform_impl/macos/event_loop.rs:155:21
  42: tao::event_loop::EventLoop<T>::run
             at /Users/alitanveer/.cargo/git/checkouts/tao-5e7ba162f074538b/d72b1e1/src/event_loop.rs:179:5
  43: dioxus_desktop::launch_with_props
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/desktop/src/lib.rs:119:5
  44: dioxus_desktop::launch
             at /Users/alitanveer/.cargo/git/checkouts/dioxus-05269388c39d4796/606b054/packages/desktop/src/lib.rs:52:5
  45: hello_dioxus::main
             at ./src/main.rs:9:5
  46: core::ops::function::FnOnce::call_once
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ops/function.rs:248:5

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later
@dvc94ch
Copy link
Contributor

dvc94ch commented Nov 22, 2022

So did a git bisect and found 3b7b503 to be the first commit causing a crash, but the example stops working and starts giving js errors with commit 047ed1e. @Demonthos any ideas?

@ealmloff
Copy link
Member

ealmloff commented Nov 22, 2022

The value attribute is volatile (must be set every render even if it has not changed), but if it is static it does not have an id on the renderer because it never needs to be updated.

A temporary fix to this is setting value to r#"{""}"# which marks it as dynamic and assigns it a id.

This means we don't know which parts of the node will be traversed to when creating the macro. We cannot generate the traversal path (the way we assign ids on master) or using child node paths from a root (what #600 uses) without knowing if the attribute is volatile or not.

#600 rewrites this part of the code, so it is probably better to fix this either in that PR or after that PR has been merged.

@ealmloff ealmloff added the bug Something isn't working label Nov 23, 2022
@ealmloff
Copy link
Member

ealmloff commented Jan 4, 2023

This is partially fixed

It no longer panics but there is still a difference between using r#"{""}"# and "":

r#"{""}"# marks applies the volatile property (which causes the text area to clear after clicking the button), but "" does not apply the volatile property (so the text area is not cleared)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants