homotopy-io / homotopy-webclient

https://homotopy.io
26 stars 5 forks source link

Error on loading main page #16

Closed jamievicary closed 5 years ago

jamievicary commented 5 years ago

On loading the main page, the following error is displayed in the console:

bootstrap:1 Uncaught ReferenceError: window is not defined

It would be good to prevent this since the red catches the eye.

zrho commented 5 years ago

This is a webpack bug in the interaction with webworkers, see https://github.com/webpack/webpack/issues/6642. The layout code is able to run in a webworker, i.e. a separate thread. This is currently disabled to make debugging simpler, but the webworker is still created. The error message can be avoided if we avoid creating the webworker for now until we need it or webpack is fixed.

jamievicary commented 5 years ago

OK. What do you see as the value in running the layout code in a separate thread? Presumably we will only need to run layout code in response to a user action, so there is no problem blocking the main thread.

zrho commented 5 years ago

When we block the main thread, we block all user interaction. This is irrelevant for small diagrams, but for a very large diagram the user wouldn't even have the option to cancel if he misclicked and now is waiting 20s until a vast diagram is processed that he didn't care about in the first place. There are options for cooperative multitasking in the main thread, but the tradeoff between performance and reactivity can be a bit fiddly. Running layout in a separate thread is simple enough to do, and allows to retain responsiveness.

jamievicary commented 5 years ago

Fine, but then we need a separate "cancel" UI mechanic for an in-progress operation.

jamievicary commented 5 years ago

Created this as issue #20.

zrho commented 5 years ago

Clearing the diagram before it is rendered is currently hooked up to cancel the webworker layout. On Wed, 5 Sep 2018 at 14:43, jamievicary notifications@github.com wrote:

Created this as issue #20 https://github.com/jamievicary/homotopy.io/issues/20.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jamievicary/homotopy.io/issues/16#issuecomment-418716320, or mute the thread https://github.com/notifications/unsubscribe-auth/AAV1JX0UYTE5xTaebVwliP6tcEV-YGh6ks5uX8bggaJpZM4WaygS .

jamievicary commented 5 years ago

OK, that's fine for now.