Handle subsecond updates asynchronously in Dioxus
Try to resolve DioxusLabs/dioxus#4902.
I closed the other PR since we definitely don't want to run all handlers async, but you said this is the branch you're using to dev against. I don't see how this change would fix an issue where we're borrowing the dom twice, unless an event is actively being handled while we process the hotpatch. That being said, I do see this issue pop up with use_resource so there might be an issue with the async polling and setting the runtime.
Do you have a more concrete repro I could work against to see what's actually happening here?
Hullo! I haven't seen an instance of this error pop up since I put this patch on the branch I use for dev.
It's been a moment since I opened this PR, but if I recall correctly, the gist is that hot patching is somehow happening while this RefCell in wasm-bindgen-futures is borrowed. You can see that in the panic on the first line:
wasm-bindgen-futures-0.4.54/src/task/singlethreadRefCell already borrowed
In my setup I'm likely spawning a lot more futures than a base Dioxus app, because I have various future loops (akin to setTimeout), which run forever. So it's almost a given that every few hot patches it'll panic like this.
As for the other PR – I would guess that any uses of Subsecond on WASM using futures would run into this issue, so I'm not certain that a Dioxus-specific fix is the way?
I can't pause to produce a repro right this second, but I suspect that this should show up very rapidly if trying to hot patch an app that creates a simple future loop with gloo's timers (really just setTimeout) or something akin. I'll try to supply a proper repro if I get a spare moment though!