fonsp / Pluto.jl

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

Pluto notebook freeze unexpectedly on warnings #659

Closed GiggleLiu closed 3 years ago

GiggleLiu commented 3 years ago

One of my Pluto notebook freeze on warnings. It is not a fancy notebook, but it freezes quite often.

https://github.com/TensorBFS/TropicalTensors.jl/blob/master/notebooks/spinglass.jl

I notice that the if I remove the warnings. It does not freeze anymore. Maybe the warning is not handled properly! The warning is redirected to the browser console

Logging.js:21 ┌ Warn: Input type of `ArrayReg` is not Complex, got TropicalNumbers.CountingTropical{Float64}
handle_log @ Logging.js:21
2Logging.js:21 ┌ Warn: Input type of `ArrayReg` is not Complex, got TropicalNumbers.Tropical{Float64}

Also, wondering why can not I suppress the warning in a Pluto notebook with Suppressor?

fonsp commented 3 years ago

(@info, @warn, etc. are always redirected to the browser console - a hidden feature!)

GiggleLiu commented 3 years ago

(@info, @warn, etc. are always redirected to the browser console - a hidden feature!)

The feature sounds good. But freezing after several warnings (like 10 warnings or so will trigger this bug) is an urgent bug because it is so hard to identify and so easy to depress users (I won't tell you I spent a whole afternoon to figure it out). Let me see if I can write some MWE to examplify this better.

ericphanson commented 3 years ago

I updated from Pluto 0.12.4 to 0.12.7 and ran into something similar. I ran my notebook, hit the following warning, and then it froze. Restarting Julia + Pluto didn't help (same thing happened). Reverted to 0.12.4 (glad I checked in the manifest!) and everything works fine, no warnings nor freezes.


┌ Warning: Failed to write to WebSocket of 1fpq1j9                        
│   exception =                                                           
│    MethodError: no method matching +(::Nothing, ::UInt8)                
│    Closest candidates are:                                              
│      +(::Any, ::Any, ::Any, ::Any...) at operators.jl:538               
│      +(::Missing, ::Number) at missing.jl:115                           
│      +(::Base.CoreLogging.LogLevel, ::Integer) at logging.jl:116        
│      ...                                                                
│    Stacktrace:                                                          
│     [1] to_msgpack(::MsgPack.ExtensionType, ::Array{Union{},1}) at /home
/ec2-user/.julia/packages/Pluto/xPnTl/src/webserver/MsgPack.jl:35         
│     [2] pack_type(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MsgPack.Exte
nsionType, ::Array{Union{},1}) at /home/ec2-user/.julia/packages/MsgPack/p
N9xd/src/pack.jl:310                                                      
│     [3] pack(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Union{},1})
 at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/pack.jl:25           
│     [4] pack_format(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MsgPack.Ma
pFixFormat, ::Dict{Symbol,Any}) at /home/ec2-user/.julia/packages/MsgPack/
pN9xd/src/pack.jl:283                                                     
│     [5] pack_type at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/pa
ck.jl:273 [inlined]                                                       
│     [6] pack at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/pack.jl
:25 [inlined]                                                             
│     [7] pack_format(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MsgPack.Ar
rayFixFormat, ::Tuple{Dict{Symbol,Any},MIME{Symbol("application/vnd.pluto.
tree+object")}}) at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/pack.
jl:246                                                                    
│     [8] pack_type at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/pa
ck.jl:237 [inlined]                                                       
│     ... (the last 3 lines are repeated 1 more time)                     
│     [12] pack(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Tuple{Symbol,Tup
le{Dict{Symbol,Any},MIME{Symbol("application/vnd.pluto.tree+object")}}}) a
t /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/pack.jl:25
│     [13] pack_format(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MsgPack.A
rrayFixFormat, ::Array{Tuple{Symbol,Tuple{Any,MIME}},1}) at /home/ec2-user
/.julia/packages/MsgPack/pN9xd/src/pack.jl:246
│     [14] pack_type at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/p
ack.jl:237 [inlined]
│     [15] pack(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Tuple{Symb
ol,Tuple{Any,MIME}},1}) at /home/ec2-user/.julia/packages/MsgPack/pN9xd/sr
c/pack.jl:25
│     [16] pack_format(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MsgPack.M
apFixFormat, ::Dict{Symbol,Any}) at /home/ec2-user/.julia/packages/MsgPack
/pN9xd/src/pack.jl:283
│     [17] pack_type at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/p
ack.jl:273 [inlined]
│     [18] pack at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/pack.j
l:25 [inlined]
│     [19] pack_format(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MsgPack.A
rrayFixFormat, ::Tuple{Dict{Symbol,Any},MIME{Symbol("application/vnd.pluto
.tree+object")}}) at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/pack
.jl:246
│     [20] pack_type at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/p
ack.jl:237 [inlined]
│     ... (the last 3 lines are repeated 2 more times)
│     ... (the last 12 lines are repeated 1 more time)
│     [39] pack(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Tuple{Symb
ol,Tuple{Dict{Symbol,Any},MIME{Symbol("application/vnd.pluto.tree+object")
}}},1}) at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/pack.jl:25
│     [40] pack_format(::Base.GenericIOBuffer{Array{UInt8,1}}, ::MsgPack.M
apFixFormat, ::Dict{Symbol,Any}) at /home/ec2-user/.julia/packages/MsgPack
/pN9xd/src/pack.jl:283
│     [41] pack_type at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/p
ack.jl:273 [inlined]
│     ... (the last 3 lines are repeated 3 more times)
│     [51] pack(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Dict{Symbol,Any}
) at /home/ec2-user/.julia/packages/MsgPack/pN9xd/src/pack.jl:25
│     [52] pack(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Vararg{Any,N} wh
ere N) at /home/ec2-user/.julia/packages/Pluto/xPnTl/src/webserver/MsgPack
.jl:72
│     [53] serialize_message_to_stream(::Base.GenericIOBuffer{Array{UInt8,
1}}, ::Pluto.UpdateMessage) at /home/ec2-user/.julia/packages/Pluto/xPnTl/
src/webserver/PutUpdates.jl:15                                            
│     [54] sprint(::Function, ::Pluto.UpdateMessage; context::Nothing, siz
ehint::Int64) at ./strings/io.jl:105
│     [55] sprint at ./strings/io.jl:101 [inlined]
│     [56] serialize_message at /home/ec2-user/.julia/packages/Pluto/xPnTl
/src/webserver/PutUpdates.jl:19 [inlined]
│     [57] flushclient(::Pluto.ClientSession) at /home/ec2-user/.julia/pac
kages/Pluto/xPnTl/src/webserver/PutUpdates.jl:73
│     [58] flushallclients(::Pluto.ServerSession, ::Array{Pluto.ClientSess
ion,1}) at /home/ec2-user/.julia/packages/Pluto/xPnTl/src/webserver/PutUpd
ates.jl:97
│     [59] putnotebookupdates!(::Pluto.ServerSession, ::Pluto.Notebook, ::
Pluto.UpdateMessage; flush::Bool) at /home/ec2-user/.julia/packages/Pluto/
xPnTl/src/webserver/PutUpdates.jl:31
│     [60] putnotebookupdates! at /home/ec2-user/.julia/packages/Pluto/xPn
Tl/src/webserver/PutUpdates.jl:24 [inlined]
│     [61] run_reactive!(::Pluto.ServerSession, ::Pluto.Notebook, ::Pluto.
NotebookTopology, ::Pluto.NotebookTopology, ::Array{Pluto.Cell,1}; deletio
n_hook::Function, persist_js_state::Bool) at /home/ec2-user/.julia/package
s/Pluto/xPnTl/src/evaluation/Run.jl:83
│     [62] run_reactive! at /home/ec2-user/.julia/packages/Pluto/xPnTl/src
/evaluation/Run.jl:26 [inlined]
│     [63] macro expansion at /home/ec2-user/.julia/packages/Pluto/xPnTl/s
rc/evaluation/Run.jl:13 [inlined]
└ @ Pluto ~/.julia/packages/Pluto/xPnTl/src/webserver/PutUpdates.jl:84
fonsp commented 3 years ago

Thank you @ericphanson! I also found the error you sent -- it will be fixed in #646

ericphanson commented 3 years ago

I've happily updated to 0.12.10 (which I understand includes #646) and have not had this issue again. @GiggleLiu maybe try that version?

GiggleLiu commented 3 years ago

Unfortunately, it does not fix my issue. In my case, there is no error information like you showed. I looks nornal in either the console or the Julia REPL, except the page is not reactive anymore.

FYI:

Browser Console log

Logging.js:21 ┌ Warn: Input type of `ArrayReg` is not Complex, got TropicalNumbers.CountingTropical{Float64}
handle_log @ Logging.js:21
2Logging.js:21 ┌ Warn: Input type of `ArrayReg` is not Complex, got TropicalNumbers.Tropical{Float64}
handle_log @ Logging.js:21
2Logging.js:21 ┌ Warn: Input type of `ArrayReg` is not Complex, got TropicalNumbers.CountingTropical{Float64}
handle_log @ Logging.js:21
2Logging.js:21 ┌ Warn: Input type of `ArrayReg` is not Complex, got TropicalNumbers.Tropical{Float64}
handle_log @ Logging.js:21
2Logging.js:21 ┌ Warn: Input type of `ArrayReg` is not Complex, got TropicalNumbers.CountingTropical{Float64}

Julia REPL log

I opened the notebook from inside of a package.

julia> notebook("spinglass"; dev=true)

Opening http://localhost:1236/open?secret=sp0CNe4z&path=%2Fhome%2Fleo%2F.julia%2Fdev%2FTropicalTensors%2Fnotebooks%2Fspinglass.jl in your default browser... ~ have fun!

Press Ctrl+C in this terminal to stop Pluto

Opening in existing browser session.
┌ Warning: Input type of `ArrayReg` is not Complex, got TropicalNumbers.CountingTropical{Float64}
└ @ YaoArrayRegister ~/.julia/packages/YaoArrayRegister/MXjQI/src/register.jl:54
┌ Warning: Input type of `ArrayReg` is not Complex, got TropicalNumbers.CountingTropical{Float64}
└ @ YaoArrayRegister ~/.julia/packages/YaoArrayRegister/MXjQI/src/register.jl:54
      From worker 3:    Compose.SVG(140.0mm, 140.0mm, IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=40595, maxsize=Inf, ptr=40596, mark=-1), nothing, "img-b7395985", 0, Compose.SVGPropertyFrame[], Dict{Type,Union{Nothing, Compose.Property}}(Compose.Property{Compose.StrokePrimitive} => nothing,Compose.Property{Compose.FillPrimitive} => nothing,Compose.Property{Compose.LineWidthPrimitive} => nothing), OrderedCollections.OrderedDict{Compose.ClipPrimitive,String}(), Tuple{Compose.FormPrimitive,String}[], Set{AbstractString}(), true, false, nothing, true, "img-b7395985-2", false, 2, Set{AbstractString}(), Set(Tuple{AbstractString,AbstractString}[("Snap.svg", "Snap")]), AbstractString[], false, :none, ())Compose.SVG(140.0mm, 140.0mm, IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=41706, maxsize=Inf, ptr=41707, mark=-1), nothing, "img-d351327d", 0, Compose.SVGPropertyFrame[], Dict{Type,Union{Nothing, Compose.Property}}(Compose.Property{Compose.FontSizePrimitive} => nothing,Compose.Property{Compose.StrokePrimitive} => nothing,Compose.Property{Compose.FillPrimitive} => nothing,Compose.Property{Compose.LineWidthPrimitive} => nothing), OrderedCollections.OrderedDict{Compose.ClipPrimitive,String}(), Tuple{Compose.FormPrimitive,String}[], Set{AbstractString}(), true, false, nothing, true, "img-d351327d-4", false, 4, Set{AbstractString}(), Set(Tuple{AbstractString,AbstractString}[("Snap.svg", "Snap")]), AbstractString[], false, :none, ())Layer 1/10
      From worker 3:    Layer 2/10
      From worker 3:    Layer 3/10
      From worker 3:    Layer 4/10
      From worker 3:    Layer 5/10
      From worker 3:    Layer 6/10
      From worker 3:    Layer 7/10
      From worker 3:    Layer 8/10
      From worker 3:    Layer 9/10
      From worker 3:    Layer 10/10
┌ Warning: Input type of `ArrayReg` is not Complex, got TropicalNumbers.Tropical{Float64}
└ @ YaoArrayRegister ~/.julia/packages/YaoArrayRegister/MXjQI/src/register.jl:54
┌ Warning: Input type of `ArrayReg` is not Complex, got TropicalNumbers.Tropical{Float64}
└ @ YaoArrayRegister ~/.julia/packages/YaoArrayRegister/MXjQI/src/register.jl:54
      From worker 3:    Layer 1/10, stack size: 0 & 0
      From worker 3:    Layer 2/10, stack size: 0 & 0
      From worker 3:    Layer 3/10, stack size: 0 & 1
      From worker 3:    Layer 4/10, stack size: 0 & 2
      From worker 3:    Layer 5/10, stack size: 0 & 3
      From worker 3:    Layer 6/10, stack size: 0 & 4
      From worker 3:    Layer 7/10, stack size: 0 & 5
      From worker 3:    Layer 8/10, stack size: 0 & 6
      From worker 3:    Layer 9/10, stack size: 0 & 7
      From worker 3:    Layer 10/10, stack size: 0 & 8
      From worker 3:    Layer 10/10, stack size: 0 & 8
      From worker 3:    Layer 9/10, stack size: 0 & 7
      From worker 3:    Layer 8/10, stack size: 0 & 6
      From worker 3:    Layer 7/10, stack size: 0 & 5
      From worker 3:    Layer 6/10, stack size: 0 & 4
      From worker 3:    Layer 5/10, stack size: 0 & 3
      From worker 3:    Layer 4/10, stack size: 0 & 2
      From worker 3:    Layer 3/10, stack size: 0 & 1
      From worker 3:    Layer 2/10, stack size: 0 & 0
      From worker 3:    Layer 1/10, stack size: 0 & 0
┌ Warning: Input type of `ArrayReg` is not Complex, got TropicalNumbers.CountingTropical{Float64}
└ @ YaoArrayRegister ~/.julia/packages/YaoArrayRegister/MXjQI/src/register.jl:54
┌ Warning: Input type of `ArrayReg` is not Complex, got TropicalNumbers.CountingTropical{Float64}
└ @ YaoArrayRegister ~/.julia/packages/YaoArrayRegister/MXjQI/src/register.jl:54
      From worker 3:    Compose.SVG(140.0mm, 140.0mm, IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=28489, maxsize=Inf, ptr=28490, mark=-1), nothing, "img-3f809010", 0, Compose.SVGPropertyFrame[], Dict{Type,Union{Nothing, Compose.Property}}(Compose.Property{Compose.StrokePrimitive} => nothing,Compose.Property{Compose.FillPrimitive} => nothing,Compose.Property{Compose.LineWidthPrimitive} => nothing), OrderedCollections.OrderedDict{Compose.ClipPrimitive,String}(), Tuple{Compose.FormPrimitive,String}[], Set{AbstractString}(), true, false, nothing, true, "img-3f809010-4", false, 4, Set{AbstractString}(), Set(Tuple{AbstractString,AbstractString}[("Snap.svg", "Snap")]), AbstractString[], false, :none, ())Layer 1/7
      From worker 3:    Layer 2/7
      From worker 3:    Layer 3/7
      From worker 3:    Layer 4/7
      From worker 3:    Layer 5/7
      From worker 3:    Layer 6/7
      From worker 3:    Layer 7/7
┌ Warning: Input type of `ArrayReg` is not Complex, got TropicalNumbers.Tropical{Float64}
└ @ YaoArrayRegister ~/.julia/packages/YaoArrayRegister/MXjQI/src/register.jl:54
┌ Warning: Input type of `ArrayReg` is not Complex, got TropicalNumbers.Tropical{Float64}
└ @ YaoArrayRegister ~/.julia/packages/YaoArrayRegister/MXjQI/src/register.jl:54
      From worker 3:    Layer 1/7, stack size: 0 & 0
      From worker 3:    Layer 2/7, stack size: 0 & 0
      From worker 3:    Layer 3/7, stack size: 0 & 1
      From worker 3:    Layer 4/7, stack size: 0 & 2
      From worker 3:    Layer 5/7, stack size: 0 & 3
      From worker 3:    Layer 6/7, stack size: 0 & 4
      From worker 3:    Layer 7/7, stack size: 0 & 5
      From worker 3:    Layer 7/7, stack size: 0 & 5
      From worker 3:    Layer 6/7, stack size: 0 & 4
      From worker 3:    Layer 5/7, stack size: 0 & 3
      From worker 3:    Layer 4/7, stack size: 0 & 2
      From worker 3:    Layer 3/7, stack size: 0 & 1
      From worker 3:    Layer 2/7, stack size: 0 & 0
      From worker 3:    Layer 1/7, stack size: 0 & 0
┌ Warning: Input type of `ArrayReg` is not Complex, got TropicalNumbers.CountingTropical{Float64}
└ @ YaoArrayRegister ~/.julia/packages/YaoArrayRegister/MXjQI/src/register.jl:54
┌ Warning: Input type of `ArrayReg` is not Complex, got TropicalNumbers.CountingTropical{Float64}
└ @ YaoArrayRegister ~/.julia/packages/YaoArrayRegister/MXjQI/src/register.jl:54
      From worker 3:    Compose.SVG(140.0mm, 140.0mm, IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=28223, maxsize=Inf, ptr=28224, mark=-1), nothing, "img-4701f371", 0, Compose.SVGPropertyFrame[], Dict{Type,Union{Nothing, Compose.Property}}(Compose.Property{Compose.StrokePrimitive} => nothing,Compose.Property{Compose.FillPrimitive} => nothing,Compose.Property{Compose.LineWidthPrimitive} => nothing), OrderedCollections.OrderedDict{Compose.ClipPrimitive,String}(), Tuple{Compose.FormPrimitive,String}[], Set{AbstractString}(), true, false, nothing, true, "img-4701f371-2", false, 2, Set{AbstractString}(), Set(Tuple{AbstractString,AbstractString}[("Snap.svg", "Snap")]), AbstractString[], false, :none, ())Compose.SVG(140.0mm, 140.0mm, IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=29034, maxsize=Inf, ptr=29035, mark=-1), nothing, "img-d763c521", 0, Compose.SVGPropertyFrame[], Dict{Type,Union{Nothing, Compose.Property}}(Compose.Property{Compose.FontSizePrimitive} => nothing,Compose.Property{Compose.StrokePrimitive} => nothing,Compose.Property{Compose.FillPrimitive} => nothing,Compose.Property{Compose.LineWidthPrimitive} => nothing), OrderedCollections.OrderedDict{Compose.ClipPrimitive,String}(), Tuple{Compose.FormPrimitive,String}[], Set{AbstractString}(), true, false, nothing, true, "img-d763c521-4", false, 4, Set{AbstractString}(), Set(Tuple{AbstractString,AbstractString}[("Snap.svg", "Snap")]), AbstractString[], false, :none, ())Compose.SVG(140.0mm, 140.0mm, IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=19814, maxsize=Inf, ptr=19815, mark=-1), nothing, "img-0a56250f", 0, Compose.SVGPropertyFrame[], Dict{Type,Union{Nothing, Compose.Property}}(Compose.Property{Compose.StrokePrimitive} => nothing,Compose.Property{Compose.FillPrimitive} => nothing,Compose.Property{Compose.LineWidthPrimitive} => nothing), OrderedCollections.OrderedDict{Compose.ClipPrimitive,String}(), Tuple{Compose.FormPrimitive,String}[], Set{AbstractString}(), true, false, nothing, true, "img-0a56250f-4", false, 4, Set{AbstractString}(), Set(Tuple{AbstractString,AbstractString}[("Snap.svg", "Snap")]), AbstractString[], false, :none, ())Layer 1/7
      From worker 3:    Layer 2/7
      From worker 3:    Layer 3/7
      From worker 3:    Layer 4/7
      From worker 3:    Layer 5/7
      From worker 3:    Layer 6/7
      From worker 3:    Layer 7/7

The script to open this notebook

using Pluto

export notebook

project_relative_path(xs...) = normpath(joinpath(dirname(dirname(pathof(@__MODULE__))), xs...))

"""
    notebook(which; dev=false, kwargs...)

Open a notebook, the first argument can be
* "spinglass": solving spinglass model with Yao.
* "randomgraph": solving randomgraph model with tensor network contraction.
"""
function notebook(which; dev=false, kwargs...)
    src = project_relative_path("notebooks", "$which.jl")
    if dev
        dest = src
    else
        dest = tempname()
        cp(src, dest)
        chmod(dest, 0o664)
    end
    Pluto.run(; notebook=dest, project=project_relative_path(), kwargs...)
end
GiggleLiu commented 3 years ago

I had Pluto froze in 0.12.10 while trying to install a package, and it never pases the "loading..." screen even in a new session. I think this is related to this issue.

Did you see any warnings in your REPL? In my case, it does not freeze anymore after I removed the warning statements.

fonsp commented 3 years ago

@GiggleLiu Is this still an issue? Can you give an example notebook?

GiggleLiu commented 3 years ago

Hi, sorry, I can not reproduce the issue at the moment. Maybe we can close it first and see if it happens again in the future.

fonsp commented 3 years ago

Okay! Was the crash caused by:

  1. A specific type of warning message, or
  2. too many warnings (of any kind)?
joshday commented 3 years ago

I recently discovered that after using Pluto inside a notebook, it would freeze after 10 @info statements. I can reproduce it with a simple notebook:

# Cell 1
using Pluto

# Cell 2
for i in 1:20
    @info i
end

The last thing I see in my terminal is [ Info: 10 and the notebook becomes unresponsive.

I'm on a Mac/Safari/Pluto v0.12.20


I don't think it's common to have using Pluto in a notebook. In my particular case I was creating HTML files based on user input and borrowing the CSS files in joinpath(pathof(Pluto), "frontend") so that the style of these files matched the notebook.

fonsp commented 3 years ago

(Sorry, I told @joshday to post their report to this issue, but later realized that it is unrelated, so I moved it to #905)