Code Monkey home page Code Monkey logo

Comments (6)

flosse avatar flosse commented on May 27, 2024

thanks for reporting!

from seed.

wkordalski avatar wkordalski commented on May 27, 2024

It turns out that switching
from "websocket send-and-receive" as an asynchronous task
to timer-based asynchronous task
also reveals this bug.

As the timer-based example can be easier to analyze, I pushed timer-based version to repository on branch with-timers

from seed.

flosse avatar flosse commented on May 27, 2024

@wkordalski thanks for the example in the repo. I can reproduce the described behavior.
Since i was not much involved in the changes in the v0.9 release, it is hard for me to guess what the cause could be.
@MartinKavik or @fosskers do you have a guess?

from seed.

MartinKavik avatar MartinKavik commented on May 27, 2024

The example is too big for me to quickly orient in it by myself and imagine all possible cases, so only some general ideas:

  1. ElRef integration to Seed rendering system was a bit painful and error-prone if I remember correctly. I wouldn't be too much surprised if there is a bug / unhandled edge case.
  2. I'm not sure if it's possible to accidentally call some_elref.get() during the rendering when the diff algorithm is just removing / reattaching new DOM elements - just an idea because async & websockets have been mentioned.
  3. I had some similar ElRef-related problems in the past but there were my mistakes in all cases (forgotten skip(), wrong assumption that DOM elements have been already rendered, etc.)

Sorry I can't help more, gl 🙂

from seed.

wkordalski avatar wkordalski commented on May 27, 2024

The example is too big for me to quickly orient in it by myself and imagine all possible cases

Sorry. I've reduced example size from around 5k LOC to 250 LOC (counting Rust only), and I feel it can be hard to reduce more.

  1. ElRef integration to Seed rendering system was a bit painful and error-prone if I remember correctly. I wouldn't be too much surprised if there is a bug / unhandled edge case.

I won't be surprised too.

  1. I'm not sure if it's possible to accidentally call some_elref.get() during the rendering when the diff algorithm is just removing / reattaching new DOM elements - just an idea because async & websockets have been mentioned.

As I know, whole Seed app and timers run on a single thread and the async tasks are scheduled using non-preemptive scheduler (run setInterval(handler, 1000); while (true) {} and see that handler is never called). Thus some_elref.get() inside update should not be executed during DOM update.

What is more, replacing assert_eq!(...) with if ... { seed::log!(...) } shows that ElRef never gets attached and the node is being rendered. So this cannot be the case that "we asked ElRef too early", but rather "we created the ElRef wrongly".

  1. I had some similar ElRef-related problems in the past but there were my mistakes in all cases (forgotten skip(), wrong assumption that DOM elements have been already rendered, etc.)

This might be. Especially that the documentation of ElRef is concise and misses the conditions the programmer should hold to But why the problem does not appear in Seed 0.8?


Generally thank you very much for your hints and ideas!
(And for your work that resulted in Seed 0.8, which is usable in our use-case).
I don't even expect that you or someone else fix this problem as our usage of Seed is quite nonstandard.

I hope that this report will help somebody who meet a similar problem or while fixing another bug.
Currently we can stay with Seed 0.8 and maybe fix this bug in the future when money allow us to do so :)

from seed.

wkordalski avatar wkordalski commented on May 27, 2024

Ok... At least I did git bisect and it turns out that that commit 5a4e91b introduces this bug.

5a4e91b36e4fa055d7f9e441171b12a3c889dfa5 is the first bad commit
commit 5a4e91b36e4fa055d7f9e441171b12a3c889dfa5
Author: glennsl <[email protected]>
Date:   Sun Oct 3 23:32:34 2021 +0200

    refactor(virtual_dom): simplify/deduplicate wiring related to DOM insertion

 src/browser/dom/virtual_dom_bridge.rs | 77 +++++++++++++++++++++--------------
 src/virtual_dom/patch.rs              | 23 +----------
 2 files changed, 48 insertions(+), 52 deletions(-)

from seed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.