repl icon indicating copy to clipboard operation
repl copied to clipboard

Flickering state in HMR

Open MangelMaxime opened this issue 6 years ago • 3 comments

When working on my canvas experimentation I had the same Flickering problem with HMR.

For me it was due to event registration using addEventListener because the previous one isn't removed moving the mouse for example still trigger the old one and because the previous Elmish app isn't destroyed there is some kind of a conflict probably and depending on which event take place the App 1 or 2 render.

Edit: I put it here just so we can later take a look at this issue if needed and if we have the time for it.

MangelMaxime avatar Aug 16 '18 20:08 MangelMaxime

I discover yesterday that we have a addEventListener listening for the URL change. It's could be one of the cause.

In Elmish the toNavigable module check if the previous URL is defferent from the new one. This limit the HMR problem for Elmish application.

MangelMaxime avatar Sep 05 '18 08:09 MangelMaxime

Ah, it can be. Does HMR work if we remove the hash change event listener? I did it thinking of the REPL in a frame where you would send new code through params, but we're getting more events now. If this is indeed the problem, I can think of two solutions:

  • Disable the event listener in debug mode with #if !DEBUG (easiest)
  • Implement Elmish navigation so it's easier to manage more actions through the URL

alfonsogarciacaro avatar Sep 05 '18 09:09 alfonsogarciacaro

I don't know yet. I just discover this event listener yesterday when reviewing the PR for #reset.

I am planning to remove current listener and use Elmish navigation module so it's more standard. :)

I think we do have others listener attach at other places. Will probably take a look at the issues in the REPL later this week.

MangelMaxime avatar Sep 05 '18 09:09 MangelMaxime