Observable freezes or crashes

Hi there!

I created the following observable:

Sometimes when I try to open it, it freezes and I cannot do anything but to kill the process.
Or the load is incomplete (often also leads to frozen screen)

My guess is out of 20 calls, 3-5 times the above situation happens.
I assume the reason for this is the second cell, where I include an iframe in which the following code runs:

The code contains setTimeout calls (in animateStars.js) and probably more importantly requestAnimationFrame calls (in stars.js). This in combination with the cell update mechanisms of observable might lead to problems.
Adjusting my code seems too much effort, but I think I don’t reference this cell from any other cell. So my understanding is it will be evaluated just once.

Any ideas what I can do ? Or any suggestions what not to include in observables in my future notebooks?


Yup, the iframe content itself is very taxing on the CPU and is likely consuming all available resources, locking up/crashing your tab in the process. Other than that it doesn’t affect your notebook in any way though, because it’s a different browsing context.

On a related note, your cell in which you call transitionNext() does not “clean up after itself”. You can see this by repeatedly saving the cell. In general you’ll want to make sure that e.g. loops stop if the cell is invalidated/refreshed, otherwise they’ll continue to run in the background and even keep references to the (now detached) DOM elements.

1 Like