fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.94k stars 285 forks source link

Startup is loading forever in Firefox #859

Closed MrDataPsycho closed 3 years ago

MrDataPsycho commented 3 years ago

Hi, when starting the Pluto.run() in my default Firefox browser it loads forever. But if I copy the url and secret to my Cromium based browser then the url ones fine. Some time it shows the following message in the console:

But no error is printed in the colsole. Is that a problem only with Firefox?

MrDataPsycho commented 3 years ago

Ok, So now it throws the following warning after I open it in another Cromium based browser.

┌ Warning: Response function to message of type complete failed
â”” @ Pluto ~/.julia/packages/Pluto/luIaC/src/webserver/WebServer.jl:359
┌ Warning: Reading WebSocket client stream failed for unknown reason:
│   parentbody =
│    Dict{Any,Any} with 5 entries:
│      "client_id"   => "k7hprv"
│      "body"        => Dict{Any,Any}("query"=>"sq")
│      "request_id"  => "1o0258f"
│      "notebook_id" => "4e19c11a-592b-11eb-0051-e3f24e17a6c3"
│      "type"        => "complete"
│   exception =
│    KeyError: key :k7hprv not found
│    Stacktrace:
│     [1] getindex at ./dict.jl:467 [inlined]
│     [2] putclientupdates! at /home/datapsycho/.julia/packages/Pluto/luIaC/src/webserver/PutUpdates.jl:56 [inlined]
│     [3] (::Pluto.var"#201#203")(::Pluto.ServerSession, ::Dict{Any,Any}, ::Pluto.Notebook; initiator::Pluto.Initiator) at /home/datapsycho/.julia/packages/Pluto/luIaC/src/webserver/REPLTools.jl:81
│     [4] process_ws_message(::Pluto.ServerSession, ::Dict{Any,Any}, ::HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at /home/datapsycho/.julia/packages/Pluto/luIaC/src/webserver/WebServer.jl:357
│     [5] (::Pluto.var"#215#225"{Pluto.ServerSession,Base.RefValue{Function}})(::HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at /home/datapsycho/.julia/packages/Pluto/luIaC/src/webserver/WebServer.jl:160
│     [6] upgrade(::Pluto.var"#215#225"{Pluto.ServerSession,Base.RefValue{Function}}, ::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}; binary::Bool) at /home/datapsycho/.julia/packages/HTTP/hbs7O/src/WebSockets.jl:160
│     [7] upgrade at /home/datapsycho/.julia/packages/HTTP/hbs7O/src/WebSockets.jl:142 [inlined]
│     [8] (::Pluto.var"#214#224"{Pluto.ServerSession,HTTP.Handlers.Router{Symbol("##260")},Base.RefValue{Function}})(::HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}) at /home/datapsycho/.julia/packages/Pluto/luIaC/src/webserver/WebServer.jl:147
│     [9] handle at /home/datapsycho/.julia/packages/HTTP/hbs7O/src/Handlers.jl:270 [inlined]
│     [10] #4 at /home/datapsycho/.julia/packages/HTTP/hbs7O/src/Handlers.jl:346 [inlined]
│     [11] macro expansion at /home/datapsycho/.julia/packages/HTTP/hbs7O/src/Servers.jl:402 [inlined]
│     [12] (::HTTP.Servers.var"#13#14"{HTTP.Handlers.var"#4#5"{HTTP.Handlers.StreamHandlerFunction{Pluto.var"#214#224"{Pluto.ServerSession,HTTP.Handlers.Router{Symbol("##260")},Base.RefValue{Function}}}},HTTP.ConnectionPool.Transaction{Sockets.TCPSocket},HTTP.Streams.Stream{HTTP.Messages.Request,HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})() at ./task.jl:356
â”” @ Pluto ~/.julia/packages/Pluto/luIaC/src/webserver/WebServer.jl:168
fonsp commented 3 years ago

I am not sure what error message you shared in your first message, but it looks like something internal in Firefox, can you instead share the output of the Web Console when the page is frozen? Have a look at these steps: https://github.com/fonsp/Pluto.jl/issues/553#issuecomment-706132347

MrDataPsycho commented 3 years ago

Hi,Here is the output from dev. console of the browser. When it happen first time the error is little bit different.

socket-died1

Later it continuously happen when working in the notebook.

socket-died2

Let me know thats what you are looking for or you need some thing more. These are from firefox. The other cromium based browser seems fine. Here is the only error throws in a cromium borwser:

load-error-03

fonsp commented 3 years ago

Thanks! Can you do it again, and post multiple screenshots to make sure that we see everything, including the first messages?

(You can ignore the "Failed to load resource: ... 404", that's 'supposed to happen')

pankgeorg commented 3 years ago

@DataPsycho Hey! I'm trying to reproduce this! can you give some information for OS and Firefox version? Looking forward!

pankgeorg commented 3 years ago

Also, this seems to be related to #848. Related from the web: https://github.com/meteor/meteor/issues/9255

MrDataPsycho commented 3 years ago

Hi @pankgeorg , Its a Mozilla Firefox 84.0.2 and I am running on Linux Mint 20 Ulyana. I will try to create more screen shot it might help.

MrDataPsycho commented 3 years ago

Hi @pankgeorg So I just set the Firefox as default browser and start pluto. First of all it was loading for ever. After a while it shows the welcome screen with a notification that there is a new Pluto update, I am using 0.12.18

It start with that following error: first-incidence

The through another error: second-incidence

Then I try to open a notebook. Which through following errors: third-incidence fourth-insedence

Then I try to open another notebook and it start to reconnect continuously: fifth-insedence

pankgeorg commented 3 years ago

Thank you, that is very helpful. In my computer (Windows 10, FF84.0.2 (64-bit)) it kind-of-works, though Firefox does throw this error. Investigating!

pankgeorg commented 3 years ago

Unfortunately, I can't reproduce this issue at all. Can you try in private window without extensions and post the txt again?

Thank you! P

digital-carver commented 3 years ago

Just as another data point, I can't reproduce it either, on my Firefox 86 on Linux. Pluto startup does take some time (20+ seconds), but there doesn't seem to be any error like the ones posted, except for the 404 error mentioned as 'expected' above.

fonsp commented 3 years ago

@digital-carver This sounds like it's just the waiting time for Julia's JIT compiler. Pluto is written in Julia after all.

digital-carver commented 3 years ago

I tried Pluto.run(notebook="mynotebookhere.jl", launch_browser=false), waited some time, and copy-pasted the shown URL in a Firefox tab. To my understanding, this would separate the JIT compilation time - which should be finished by the time the URL is pasted - and give us the load time alone. With this setup, a Pluto notebook still takes 20-30 seconds on average to load in Firefox.

During the long loads, 10+ seconds are spent in this near-empty page: empty tab with "localhost" as loading status.
Then, the page starts loading, with 10 to 20 seconds spent in intermediate stages like this: Pluto Loading...

I looked at the Network tab in Firefox Dev Tools window, and it looks like early css and js resources are taking 700 to 900 ms each to load: Network tab beginning
But perhaps more importantly, for some reason the logo and favicon resources take almost 10 seconds each: Network tab favicon part

The 18.8 seconds load time shown in the bottom half in the last two images counts only the second stage of the loading process, and doesn't include the ten or so seconds spent in the intitial near-empty page mentioned above. Overall, this load took around 30 seconds to load, which is around the average time from many attempts. Page refreshes and moving to other notebooks within the Pluto interface happen relatively quickly (5-6 s), presumably because the resources are cached, but stopping Pluto and loading it in a new session again brings the time back up to 20-30 s.

pankgeorg commented 3 years ago

This is very helpful @digital-carver. I will try to find the source of the delay and keep you posted! Thank you for this!

fonsp commented 3 years ago

This does not isolate JIT time, because the request is handled by Julia code, so the first request will trigger JIT. It does not make sense to measure JIT time when trying to optimize frontend loading time.

To isolate JIT, repeat an action on the frontend multiple times, only the first request will trigger JIT on the server. E.g. load the notebook, wait, and then refresh the browser.

pankgeorg commented 3 years ago

Closing due to lack of progress - let's continue in #1168 if we have new data