Add tracing to virtual_dom (#1949)
Address #1161; Add tracing to virtual dom:
- Added a dependency on [tracing-fluent-assertions](https://github.com/tobz/tracing-fluent-assertions) for test cases
- Added a test case showing tracing
example log
```
2024-02-28T21:52:25.266474Z TRACE dioxus_core::scope_context: providing context alloc::rc::Rc<dioxus_core::error_boundary::ErrorBoundary> (TypeId { t: 86211292795840746005296084033382154959 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::virtual_dom::VirtualDom::new
2024-02-28T21:52:25.266651Z TRACE dioxus_core::scope_context: looking for context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) in app
at packages/core/src/scope_context.rs:106
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266662Z TRACE dioxus_core::scope_context: context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) not found
at packages/core/src/scope_context.rs:140
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266671Z TRACE dioxus_core::scope_context: providing context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266713Z TRACE dioxus_core::scope_context: providing context dioxus_signals::reactive_context::ReactiveContext (TypeId { t: 86476382904980360086558195405008306005 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266723Z TRACE dioxus_core::scope_context: looking for context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) in app
at packages/core/src/scope_context.rs:106
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266730Z TRACE dioxus_core::scope_context: context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) not found
at packages/core/src/scope_context.rs:140
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266769Z TRACE dioxus_core::scope_context: providing context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266828Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:60:5:1728", roots: [Element { tag: "div", namespace: None, attrs: [], children: [Element { tag: "button", namespace: None, attrs: [Dynamic { id: 0 }], children: [Text { text: "+" }] }, Element { tag: "button", namespace: None, attrs: [Dynamic { id: 1 }], children: [Text { text: "-" }] }, Element { tag: "ul", namespace: None, attrs: [], children: [Dynamic { id: 0 }] }] }], node_paths: [[0, 2, 0]], attr_paths: [[0, 0], [0, 1]] } }, dynamic_nodes: [Placeholder(VPlaceholder)], dynamic_attrs: [[Attribute { name: "onclick", value: Listener, namespace: None, volatile: false }], [Attribute { name: "onclick", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(0) } }, mount: MountId(0)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266896Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.266934Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.266997Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(1) } }, mount: MountId(1)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267026Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "0" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(2) } }, mount: MountId(2)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267061Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.267084Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.267131Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(3) } }, mount: MountId(3)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267157Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "1" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(4) } }, mount: MountId(4)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267206Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.267229Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.267274Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(5) } }, mount: MountId(5)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267297Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "2" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(6) } }, mount: MountId(6)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
```
2024-02-29 23:49:35 +00:00
|
|
|
use dioxus::html::SerializedHtmlEventConverter;
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
use dioxus_core::ElementId;
|
2024-08-13 18:57:54 +00:00
|
|
|
use std::{any::Any, rc::Rc};
|
Add tracing to virtual_dom (#1949)
Address #1161; Add tracing to virtual dom:
- Added a dependency on [tracing-fluent-assertions](https://github.com/tobz/tracing-fluent-assertions) for test cases
- Added a test case showing tracing
example log
```
2024-02-28T21:52:25.266474Z TRACE dioxus_core::scope_context: providing context alloc::rc::Rc<dioxus_core::error_boundary::ErrorBoundary> (TypeId { t: 86211292795840746005296084033382154959 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::virtual_dom::VirtualDom::new
2024-02-28T21:52:25.266651Z TRACE dioxus_core::scope_context: looking for context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) in app
at packages/core/src/scope_context.rs:106
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266662Z TRACE dioxus_core::scope_context: context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) not found
at packages/core/src/scope_context.rs:140
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266671Z TRACE dioxus_core::scope_context: providing context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266713Z TRACE dioxus_core::scope_context: providing context dioxus_signals::reactive_context::ReactiveContext (TypeId { t: 86476382904980360086558195405008306005 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266723Z TRACE dioxus_core::scope_context: looking for context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) in app
at packages/core/src/scope_context.rs:106
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266730Z TRACE dioxus_core::scope_context: context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) not found
at packages/core/src/scope_context.rs:140
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266769Z TRACE dioxus_core::scope_context: providing context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266828Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:60:5:1728", roots: [Element { tag: "div", namespace: None, attrs: [], children: [Element { tag: "button", namespace: None, attrs: [Dynamic { id: 0 }], children: [Text { text: "+" }] }, Element { tag: "button", namespace: None, attrs: [Dynamic { id: 1 }], children: [Text { text: "-" }] }, Element { tag: "ul", namespace: None, attrs: [], children: [Dynamic { id: 0 }] }] }], node_paths: [[0, 2, 0]], attr_paths: [[0, 0], [0, 1]] } }, dynamic_nodes: [Placeholder(VPlaceholder)], dynamic_attrs: [[Attribute { name: "onclick", value: Listener, namespace: None, volatile: false }], [Attribute { name: "onclick", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(0) } }, mount: MountId(0)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266896Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.266934Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.266997Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(1) } }, mount: MountId(1)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267026Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "0" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(2) } }, mount: MountId(2)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267061Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.267084Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.267131Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(3) } }, mount: MountId(3)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267157Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "1" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(4) } }, mount: MountId(4)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267206Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.267229Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.267274Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(5) } }, mount: MountId(5)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267297Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "2" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(6) } }, mount: MountId(6)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
```
2024-02-29 23:49:35 +00:00
|
|
|
use tracing_fluent_assertions::{AssertionRegistry, AssertionsLayer};
|
|
|
|
use tracing_subscriber::{layer::SubscriberExt, Registry};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn basic_tracing() {
|
|
|
|
// setup tracing
|
|
|
|
let assertion_registry = AssertionRegistry::default();
|
|
|
|
let base_subscriber = Registry::default();
|
|
|
|
// log to standard out for testing
|
|
|
|
let std_out_log = tracing_subscriber::fmt::layer().pretty();
|
|
|
|
let subscriber = base_subscriber
|
|
|
|
.with(std_out_log)
|
|
|
|
.with(AssertionsLayer::new(&assertion_registry));
|
|
|
|
tracing::subscriber::set_global_default(subscriber).unwrap();
|
|
|
|
|
|
|
|
let new_virtual_dom = assertion_registry
|
|
|
|
.build()
|
|
|
|
.with_name("VirtualDom::new")
|
|
|
|
.was_created()
|
|
|
|
.was_entered_exactly(1)
|
|
|
|
.was_closed()
|
|
|
|
.finalize();
|
|
|
|
|
|
|
|
let edited_virtual_dom = assertion_registry
|
|
|
|
.build()
|
|
|
|
.with_name("VirtualDom::rebuild")
|
|
|
|
.was_created()
|
|
|
|
.was_entered_exactly(1)
|
|
|
|
.was_closed()
|
|
|
|
.finalize();
|
|
|
|
|
|
|
|
set_event_converter(Box::new(SerializedHtmlEventConverter));
|
|
|
|
let mut dom = VirtualDom::new(app);
|
|
|
|
|
|
|
|
dom.rebuild(&mut dioxus_core::NoOpMutations);
|
|
|
|
|
|
|
|
new_virtual_dom.assert();
|
|
|
|
edited_virtual_dom.assert();
|
|
|
|
|
|
|
|
for _ in 0..3 {
|
2024-08-13 18:57:54 +00:00
|
|
|
let event = Event::new(
|
|
|
|
Rc::new(PlatformEventData::new(Box::<SerializedMouseData>::default())) as Rc<dyn Any>,
|
Add tracing to virtual_dom (#1949)
Address #1161; Add tracing to virtual dom:
- Added a dependency on [tracing-fluent-assertions](https://github.com/tobz/tracing-fluent-assertions) for test cases
- Added a test case showing tracing
example log
```
2024-02-28T21:52:25.266474Z TRACE dioxus_core::scope_context: providing context alloc::rc::Rc<dioxus_core::error_boundary::ErrorBoundary> (TypeId { t: 86211292795840746005296084033382154959 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::virtual_dom::VirtualDom::new
2024-02-28T21:52:25.266651Z TRACE dioxus_core::scope_context: looking for context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) in app
at packages/core/src/scope_context.rs:106
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266662Z TRACE dioxus_core::scope_context: context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) not found
at packages/core/src/scope_context.rs:140
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266671Z TRACE dioxus_core::scope_context: providing context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266713Z TRACE dioxus_core::scope_context: providing context dioxus_signals::reactive_context::ReactiveContext (TypeId { t: 86476382904980360086558195405008306005 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266723Z TRACE dioxus_core::scope_context: looking for context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) in app
at packages/core/src/scope_context.rs:106
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266730Z TRACE dioxus_core::scope_context: context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) not found
at packages/core/src/scope_context.rs:140
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266769Z TRACE dioxus_core::scope_context: providing context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266828Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:60:5:1728", roots: [Element { tag: "div", namespace: None, attrs: [], children: [Element { tag: "button", namespace: None, attrs: [Dynamic { id: 0 }], children: [Text { text: "+" }] }, Element { tag: "button", namespace: None, attrs: [Dynamic { id: 1 }], children: [Text { text: "-" }] }, Element { tag: "ul", namespace: None, attrs: [], children: [Dynamic { id: 0 }] }] }], node_paths: [[0, 2, 0]], attr_paths: [[0, 0], [0, 1]] } }, dynamic_nodes: [Placeholder(VPlaceholder)], dynamic_attrs: [[Attribute { name: "onclick", value: Listener, namespace: None, volatile: false }], [Attribute { name: "onclick", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(0) } }, mount: MountId(0)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266896Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.266934Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.266997Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(1) } }, mount: MountId(1)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267026Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "0" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(2) } }, mount: MountId(2)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267061Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.267084Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.267131Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(3) } }, mount: MountId(3)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267157Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "1" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(4) } }, mount: MountId(4)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267206Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.267229Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.267274Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(5) } }, mount: MountId(5)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267297Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "2" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(6) } }, mount: MountId(6)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
```
2024-02-29 23:49:35 +00:00
|
|
|
true,
|
|
|
|
);
|
2024-08-13 18:57:54 +00:00
|
|
|
dom.runtime().handle_event("click", event, ElementId(2));
|
Add tracing to virtual_dom (#1949)
Address #1161; Add tracing to virtual dom:
- Added a dependency on [tracing-fluent-assertions](https://github.com/tobz/tracing-fluent-assertions) for test cases
- Added a test case showing tracing
example log
```
2024-02-28T21:52:25.266474Z TRACE dioxus_core::scope_context: providing context alloc::rc::Rc<dioxus_core::error_boundary::ErrorBoundary> (TypeId { t: 86211292795840746005296084033382154959 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::virtual_dom::VirtualDom::new
2024-02-28T21:52:25.266651Z TRACE dioxus_core::scope_context: looking for context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) in app
at packages/core/src/scope_context.rs:106
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266662Z TRACE dioxus_core::scope_context: context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) not found
at packages/core/src/scope_context.rs:140
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266671Z TRACE dioxus_core::scope_context: providing context generational_box::Owner<generational_box::sync::SyncStorage> (TypeId { t: 16187079142358387300491255137481079601 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266713Z TRACE dioxus_core::scope_context: providing context dioxus_signals::reactive_context::ReactiveContext (TypeId { t: 86476382904980360086558195405008306005 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266723Z TRACE dioxus_core::scope_context: looking for context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) in app
at packages/core/src/scope_context.rs:106
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266730Z TRACE dioxus_core::scope_context: context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) not found
at packages/core/src/scope_context.rs:140
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266769Z TRACE dioxus_core::scope_context: providing context generational_box::Owner (TypeId { t: 87785542931436862771411509553978749471 }) in app
at packages/core/src/scope_context.rs:189
in dioxus_core::scope_arena::render with scope: app
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266828Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:60:5:1728", roots: [Element { tag: "div", namespace: None, attrs: [], children: [Element { tag: "button", namespace: None, attrs: [Dynamic { id: 0 }], children: [Text { text: "+" }] }, Element { tag: "button", namespace: None, attrs: [Dynamic { id: 1 }], children: [Text { text: "-" }] }, Element { tag: "ul", namespace: None, attrs: [], children: [Dynamic { id: 0 }] }] }], node_paths: [[0, 2, 0]], attr_paths: [[0, 0], [0, 1]] } }, dynamic_nodes: [Placeholder(VPlaceholder)], dynamic_attrs: [[Attribute { name: "onclick", value: Listener, namespace: None, volatile: false }], [Attribute { name: "onclick", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(0) } }, mount: MountId(0)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::rebuild
2024-02-28T21:52:25.266896Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.266934Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.266997Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(1) } }, mount: MountId(1)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267026Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "0" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(2) } }, mount: MountId(2)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267061Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.267084Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.267131Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(3) } }, mount: MountId(3)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267157Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "1" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(4) } }, mount: MountId(4)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267206Z TRACE dioxus_core::virtual_dom: Calling 1 listeners
at packages/core/src/virtual_dom.rs:695
in dioxus_core::virtual_dom::VirtualDom::handle_bubbling_event with parent: Some(ElementRef { path: ElementPath { path: [0, 0] }, mount: MountId(0) }), name: "click"
in dioxus_core::virtual_dom::VirtualDom::handle_event with name: "click", data: Any { .. }, element: ElementId(2), bubbles: true
2024-02-28T21:52:25.267229Z TRACE dioxus_core::virtual_dom: Marking scope ScopeId(0) (app) as dirty
at packages/core/src/virtual_dom.rs:379
in dioxus_core::virtual_dom::VirtualDom::process_events
2024-02-28T21:52:25.267274Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:71:37:2059", roots: [Dynamic { id: 0 }], node_paths: [[0]], attr_paths: [] } }, dynamic_nodes: [Component(VComponent { name: "ChildExample" })], dynamic_attrs: [] }, mount: Cell { value: MountId(5) } }, mount: MountId(5)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
2024-02-28T21:52:25.267297Z INFO dioxus_core::diff::node: creating template, self: VNode { vnode: VNodeInner { key: None, template: Cell { value: Template { name: "packages/core/tests/tracing.rs:81:5:2238", roots: [Element { tag: "li", namespace: None, attrs: [Dynamic { id: 0 }], children: [DynamicText { id: 0 }] }], node_paths: [[0, 0]], attr_paths: [[0]] } }, dynamic_nodes: [Text(VText { value: "2" })], dynamic_attrs: [[Attribute { name: "onmouseover", value: Listener, namespace: None, volatile: false }]] }, mount: Cell { value: MountId(6) } }, mount: MountId(6)
at packages/core/src/diff/node.rs:547
in dioxus_core::virtual_dom::VirtualDom::render_immediate
```
2024-02-29 23:49:35 +00:00
|
|
|
dom.process_events();
|
|
|
|
_ = dom.render_immediate_to_vec();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn app() -> Element {
|
|
|
|
let mut idx = use_signal(|| 0);
|
|
|
|
let onhover = |_| println!("go!");
|
|
|
|
|
|
|
|
rsx! {
|
|
|
|
div {
|
|
|
|
button {
|
|
|
|
onclick: move |_| {
|
|
|
|
idx += 1;
|
|
|
|
println!("Clicked");
|
|
|
|
},
|
|
|
|
"+"
|
|
|
|
}
|
|
|
|
button { onclick: move |_| idx -= 1, "-" }
|
|
|
|
ul {
|
|
|
|
{(0..idx()).map(|i| rsx! {
|
|
|
|
ChildExample { i: i, onhover: onhover }
|
|
|
|
})}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[component]
|
|
|
|
fn ChildExample(i: i32, onhover: EventHandler<MouseEvent>) -> Element {
|
|
|
|
rsx! { li { onmouseover: move |e| onhover.call(e), "{i}" } }
|
|
|
|
}
|