run-wasm icon indicating copy to clipboard operation
run-wasm copied to clipboard

Fix pyodide loading without using beforeInteractive loading strategy

Open kennethcassel opened this issue 4 years ago • 7 comments

Using beforeInteractive in the next.js script component fixed the pyodide loading issue but now the experience of using the site is frustrating.

Site does the initial render but you can't scroll until pyodide loads.

Ideally we'd have some sort of loading indicator and let a user scroll on the site instead of making it hang

kennethcassel avatar Sep 25 '21 17:09 kennethcassel

Ah that's rubbish, sorry! Do you see this on desktop browsers or only mobile? I'm only seeing it on iOS (don't have any other devices to check it on), but it seems okay on desktop:

https://user-images.githubusercontent.com/1711350/134782506-cdb2752d-44a1-4291-ad57-9f1b99157798.mov

In terms of loading indicators I did add something very basic for the matplotlib one:

https://user-images.githubusercontent.com/1711350/134782521-dce8efb8-dcfa-46c7-9679-f28fbb7a3d3f.mov

We could easily add the Loading Pyodide... part of that for the main page (or a better loading indicator!)

But for that one scrolling is frozen (on mobile only for me) during the load pyodide + load matplotlib.

I'm wondering if this might be a problem with mobile + useEffect? It's a bit tricky to tell though because we have no visual indicator when that beforeInteractive script is loaded. And depends which devices you're seeing it on too.

mcintyre94 avatar Sep 25 '21 18:09 mcintyre94

Ah okay shouldn't have just assumed it was due to beforeInteractive.

I'm only seeing it on iOS mobile safari.

kennethcassel avatar Sep 25 '21 18:09 kennethcassel

I made a create-react-app project that has a useEffect fetching http://httpbin.org/delay/10 and then updating UI - on iOS Safari scrolling stays responsive (and the default spinning logo keeps spinning) during that delay. So my best guess is that the CPU is getting throttled during the load, which seems.. surprising for iOS.

Out of interest what device are you seeing this on? I'm on an iPhone XR so a few years old.

FWIW I can also repro this on a checkout of 74d856517c4a2dfa6c47c79095a02e611cd85d6e (the last commit before any of mine today) - site goes unresponsive and won't scroll until the run code button is displayed.

mcintyre94 avatar Sep 25 '21 19:09 mcintyre94

I'm on iPhone XS 14.71

kennethcassel avatar Sep 25 '21 20:09 kennethcassel

Pretty similar then, probably the same CPU. It’d be good to hear from someone on a newer device or any android device to see if we can narrow it down at all.

mcintyre94 avatar Sep 25 '21 20:09 mcintyre94

BrowserStack offers free plan for open source projects.

This can help in testing across multiple devices

hatemhosny avatar Sep 28 '21 15:09 hatemhosny

For me, scrolling is frozen on during only the Loading Pyodide...

Using it on mobile google chrome. I am on Andriod below are my phone configs. WhatsApp Image 2021-09-30 at 2 32 23 PM

shadab14meb346 avatar Sep 30 '21 09:09 shadab14meb346