Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

body! stopped working (Julia 1.0, linux) #154

Closed
zsunberg opened this issue Sep 22, 2018 · 21 comments
Closed

body! stopped working (Julia 1.0, linux) #154

zsunberg opened this issue Sep 22, 2018 · 21 comments
Labels

Comments

@zsunberg
Copy link

w = Window()
body!(w, "test")

Stopped working for me. The javascript console displays the error: Uncaught ReferenceError: Blink is not defined I have gathered from other issues that this means it is not correctly loading some javascript during initialization. However there is no other indication of what is going wrong except an "Electron Security Warning".

In an effort to fix this, I deleted everything in my .julia folder (except dev, which does not have Blink in it) and reinstalled. However the result is the same after this. Is there something else that I need to delete to completely start over from scratch?

Please assist as this is very important for another tool that I am writing: https://github.com/JuliaPOMDP/POMDPs.jl!

Thank you!

@zsunberg
Copy link
Author

Is there a way that I can try to reload main.html?

@pfitzseb pfitzseb added the bug label Sep 22, 2018
@NHDaly
Copy link
Collaborator

NHDaly commented Sep 22, 2018

Hey, let's try to start with some debugging information. What version of julia are you using? Also, ideally, can you share what packages you have installed?

If you're using a julia version >= 0.7, i think the easiest way to that is to cat your Project.toml file? Here's mine:

shell> cat ~/.julia/environments/v0.7/Project.toml
[deps]
ApplicationBuilder = "cc31668c-6ae7-53d6-850f-193f8a9a06ba"
Atom = "c52e3926-4ff0-5f6e-af25-54175e0327b1"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
Blink = "ad839575-38b3-5650-b840-f874b8c74a25"
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Example = "7876af07-990d-54b4-ab0e-23690620f79a"
Gallium = "87a02803-f0ee-5d26-846e-298423f06ab0"
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
Juno = "e5e0dc1b-0480-54bc-9374-aad01c23163d"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
OhMyREPL = "5fb14364-9ced-5910-84b2-373655c76a03"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
Query = "1a8c2f83-1ff3-5112-b086-8aa67b057ba1"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
SimpleDirectMediaLayer = "98e33af6-2ee5-5afd-9e75-cbc738b767c4"
SimpleSQL = "925d5e1e-9081-5384-b780-af3c24527763"
StatPlots = "60ddc479-9b66-56df-82fc-76a74619b69c"
VegaLite = "112f6efa-9a02-5b7d-90c0-432ed331239a"
Weave = "44d3d7a6-8a23-5bf8-98c5-b353f8df5ec9"
WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29"

@NHDaly
Copy link
Collaborator

NHDaly commented Sep 22, 2018

Ah, okay, actually, I have a guess about what might be going on.

I'm not sure why this would have been working for you previously, other than chance, but my guess is that you're seeing this problem due to the asynchronous nature of those functions. In the current release version of Blink, both of those methods are asynchronous, meaning that they return immediately, rather than blocking until the entire process is finished. So if you run those two statements too close together, back-to-back, they will fail in exactly the manner you've just described: Uncaught ReferenceError: Blink is not defined. This is because the Blink javascript hasn't been loaded yet. If you wait for a few seconds in-between those two statements it will work:

using Blink
w = Window();  sleep(5.0);   # In practice, probably just 1 or 2 seconds will be okay here, but better safe than sorry.
body!(w, "test"); sleep(1.0);  # Probably only need 0.5 seconds or so..

That should fix your problem!


However, of course, it's silly that those are async. In the master branch, there's already an option to make body! synchronous via a param async=false, and Window will get an option to be synchronous in #137.

@zsunberg
Copy link
Author

Hey @NHDaly Thanks!

julia> versioninfo()
Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

The only things in my Project.toml are Blink and Revise.

(v1.0) pkg> status
    Status `~/.julia/environments/v1.0/Project.toml`
  [ad839575] Blink v0.8.0
  [295af30f] Revise v0.7.11

You can see my manifest here: Manifest.toml.txt

If you wait for a few seconds in-between those two statements it will work:

Yeah, I definitely have tried letting it sit for a long time

julia> w = Window(); sleep(5.0);

julia> body!(w, "test"); sleep(1.0);

gives the same negative result.

Another potential useful piece of information is that the body of the window after loading it is just

<html><head></head><body></body></html>

@zsunberg
Copy link
Author

zsunberg commented Sep 22, 2018

Also:

(v1.0) pkg> test Blink
   Testing Blink
    Status `/tmp/tmpyRgCbJ/Manifest.toml`
  [bf4720bc] AssetRegistry v0.1.0
  [9e28174c] BinDeps v0.8.10
  [b99e7846] BinaryProvider v0.4.2
  [ad839575] Blink v0.8.0
  [34da2185] Compat v1.1.0
  [864edb3b] DataStructures v0.13.0
  [de31a74c] FunctionalCollections v0.4.0
  [cd3eb016] HTTP v0.7.0
  [9fb69e20] Hiccup v0.2.2
  [83e8ac13] IniFile v0.5.0
  [97c1335a] JSExpr v0.3.1
  [682c06a0] JSON v0.19.0
  [50d2b5c4] Lazy v0.13.1
  [1914dd2f] MacroTools v0.4.4
  [739be429] MbedTLS v0.6.1
  [ffc61752] Mustache v0.5.1
  [a975b10e] Mux v0.5.3
  [510215fc] Observables v0.2.2
  [bac558e1] OrderedCollections v1.0.1
  [fa939f87] Pidfile v1.1.0
  [189a3867] Reexport v0.2.0
  [ae029012] Requires v0.5.2
  [30578b45] URIParser v0.4.0
  [0f1e0344] WebIO v0.3.4
  [104b5d7c] WebSockets v1.0.0
  [cc8bc4a8] Widgets v0.4.2
  [2a0f44e3] Base64  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Base64`]
  [ade2ca70] Dates  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Dates`]
  [8bb1440f] DelimitedFiles  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/DelimitedFiles`]
  [8ba89e20] Distributed  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Distributed`]
  [7b1f6079] FileWatching  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/FileWatching`]
  [b77e0a4c] InteractiveUtils  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/InteractiveUtils`]
  [76f85450] LibGit2  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/LibGit2`]
  [8f399da3] Libdl  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Libdl`]
  [37e2e46d] LinearAlgebra  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/LinearAlgebra`]
  [56ddb016] Logging  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Logging`]
  [d6f4376e] Markdown  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Markdown`]
  [a63ad114] Mmap  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Mmap`]
  [44cfe95a] Pkg  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Pkg`]
  [de0858da] Printf  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Printf`]
  [3fa0cd96] REPL  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/REPL`]
  [9a3f8284] Random  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Random`]
  [ea8e919c] SHA  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/SHA`]
  [9e88b42a] Serialization  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Serialization`]
  [1a1011a3] SharedArrays  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/SharedArrays`]
  [6462fe0b] Sockets  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Sockets`]
  [2f01184e] SparseArrays  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/SparseArrays`]
  [10745b16] Statistics  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Statistics`]
  [8dfed614] Test  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Test`]
  [cf7118a7] UUIDs  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/UUIDs`]
  [4ec0a83e] Unicode  [`/opt/julia-1.0.0/bin/../share/julia/stdlib/v1.0/Unicode`]
Error During Test at /home/zach/.julia/packages/Blink/KMJt9/test/runtests.jl:16
  Test threw exception
  Expression: #= /home/zach/.julia/packages/Blink/KMJt9/test/runtests.jl:16 =# @js(w, Math.log(10)) ≈ log(10)
  MethodError: no method matching isapprox(::Dict{String,Any}, ::Float64)
  Closest candidates are:
    isapprox(!Matched::Missing, ::Any; kwargs...) at missing.jl:69
    isapprox(::Any, !Matched::Missing; kwargs...) at missing.jl:70
    isapprox(!Matched::Number, ::Number; atol, rtol, nans) at floatfuncs.jl:272
  Stacktrace:
   [1] eval_test(::Expr, ::Expr, ::LineNumberNode) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.0/Test/src/Test.jl:229
   [2] top-level scope at none:0
   [3] include at ./boot.jl:317 [inlined]
   [4] include_relative(::Module, ::String) at ./loading.jl:1038
   [5] include(::Module, ::String) at ./sysimg.jl:29
   [6] include(::String) at ./client.jl:388
   [7] top-level scope at none:0
   [8] eval(::Module, ::Any) at ./boot.jl:319
   [9] macro expansion at ./logging.jl:317 [inlined]
   [10] exec_options(::Base.JLOptions) at ./client.jl:219
   [11] _start() at ./client.jl:421
ERROR: LoadError: There was an error during testing
in expression starting at /home/zach/.julia/packages/Blink/KMJt9/test/runtests.jl:16
ERROR: Package Blink errored during testing

which seems to mean that it can't evaluate any js.

@pfitzseb
Copy link
Member

Yeah, I can repro this -- main.html is never loaded for me either.

@NHDaly
Copy link
Collaborator

NHDaly commented Sep 22, 2018 via email

@NHDaly
Copy link
Collaborator

NHDaly commented Sep 23, 2018

Hmm, okay, it definitely seems like the latest release of HTTP.jl broke us! :) I'm glad I've tracked it down.
https://github.com/JuliaWeb/HTTP.jl/releases/tag/v0.7.0

I can see that just reverting HTTP.jl to the previous release fixes our test:

(tmp) pkg> add HTTP#v0.6.15
  Updating git-repo `https://github.com/JuliaWeb/HTTP.jl.git`
 Resolving package versions...
┌ Warning: julia version requirement for package HTTP not satisfied
└ @ Pkg.Operations /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Operations.jl:173
  Updating `Project.toml`
  [cd3eb016] ~ HTTP v0.7.0+ #d388371 (https://github.com/JuliaWeb/HTTP.jl.git) ⇒ v0.7.0+ #382b6c3 (https://github.com/JuliaWeb/HTTP.jl.git)
  Updating `Manifest.toml`
  [cd3eb016] ~ HTTP v0.7.0+ #d388371 (https://github.com/JuliaWeb/HTTP.jl.git) ⇒ v0.7.0+ #382b6c3 (https://github.com/JuliaWeb/HTTP.jl.git)

julia0.7> using Blink
julia0.7> w = Window();
julia0.7> body!(w, "test");  # This works

That release was supposed to be about adding v0.7 support, so i guess some things might have changed. The changelog doesn't imply we need to do anything different, so maybe it's a bug on their end...

@rdeits
Copy link
Collaborator

rdeits commented Sep 23, 2018

I've been having issues in the last couple of days with the web ecosystem that were resolved by updating WebSockets.jl to master or v1.0.1. Perhaps you could try that?

@NHDaly
Copy link
Collaborator

NHDaly commented Sep 23, 2018

Mmm thanks Robin, I think you're right.

I tried updating WebSockets, but that downgraded HTTP, which didn't let me test your theory:

(tmp) pkg> add WebSockets#v1.0.1
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Updating git-repo `https://github.com/JuliaWeb/WebSockets.jl.git`
 Resolving package versions...
  Updating `Project.toml`
  [cd3eb016]  HTTP v0.7.0  v0.6.14
  [104b5d7c] + WebSockets v1.0.2+ #ce0a16d (https://github.com/JuliaWeb/WebSockets.jl.git)
  Updating `Manifest.toml`
  [cd3eb016]  HTTP v0.7.0  v0.6.14
  [104b5d7c]  WebSockets v1.0.0  v1.0.2+ #ce0a16d (https://github.com/JuliaWeb/WebSockets.jl.git)

So then I dev'd HTTP, putting it back at v0.7.0, and indeed my test now passes:

(tmp) pkg> status
    Status `Project.toml`
  [ad839575] Blink v0.8.0+ [`~/.julia/dev/Blink`]
  [132d396a] HTTP v0.7.0 [`~/.julia/dev/HTTP`]
  [104b5d7c] WebSockets v1.0.2+ #ce0a16d (https://github.com/JuliaWeb/WebSockets.jl.git)
julia0.7> using Blink
julia0.7> w = Window();
julia0.7> body!(w, "test");  # This works

So it seems that we need a newer WebSockets if we're going to be using the newer HTTP.

Does anyone understand what's controlling the installation of the various versions? Clearly it's not our REQUIRE file, since that's still asking for WebSockets 0.2.3!
https://github.com/JunoLab/Blink.jl/blob/09bc951e0dd6b566821431a6613d743363450987/REQUIRE#L2

How can we tell Julia we'd like v1.0.1+ pretty please?

@pfitzseb
Copy link
Member

pfitzseb commented Sep 23, 2018

Pretty sure you can just put

WebSockets 1.0.1

into REQUIRE, since that's a lower bound.

@NHDaly
Copy link
Collaborator

NHDaly commented Sep 23, 2018

since that's a lower bound.

Ah, thanks, that's the part I was missing. 😄

Okay cool, so I've made that change in this commit: NHDaly@fa9af71 and pushed it to this branch: https://github.com/NHDaly/Blink.jl/tree/WebSocketsDependency. This does indeed fix the bug.

On a clean project, it causes WebSockets v1.0.2 to be installed, and also for some reason downgrades HTTP back to v0.6.14:

(tmp) pkg> status
    Status `Project.toml`

(tmp) pkg> add https://github.com/NHDaly/Blink.jl#fa9af71dc
   Cloning git-repo `https://github.com/NHDaly/Blink.jl`
  Updating git-repo `https://github.com/NHDaly/Blink.jl`
 Resolving package versions...
  Updating `Project.toml`
  [ad839575] + Blink v0.8.0+ #fa9af71 (https://github.com/NHDaly/Blink.jl)
  Updating `Manifest.toml`
  [bf4720bc] + AssetRegistry v0.1.0
  [9e28174c] + BinDeps v0.8.10
  [b99e7846] + BinaryProvider v0.5.0
  [ad839575] + Blink v0.8.0+ #fa9af71 (https://github.com/NHDaly/Blink.jl)
  [34da2185] + Compat v1.1.0
  [864edb3b] + DataStructures v0.13.0
  [de31a74c] + FunctionalCollections v0.4.0
  [cd3eb016] + HTTP v0.6.14
  [9fb69e20] + Hiccup v0.2.2
  [83e8ac13] + IniFile v0.5.0
  [97c1335a] + JSExpr v0.3.1
  [682c06a0] + JSON v0.19.0
  [50d2b5c4] + Lazy v0.13.1
  [1914dd2f] + MacroTools v0.4.4
  [739be429] + MbedTLS v0.6.2
  [ffc61752] + Mustache v0.5.2
  [a975b10e] + Mux v0.5.3
  [510215fc] + Observables v0.2.2
  [bac558e1] + OrderedCollections v1.0.1
  [fa939f87] + Pidfile v1.1.0
  [189a3867] + Reexport v0.2.0
  [ae029012] + Requires v0.5.2
  [30578b45] + URIParser v0.4.0
  [0f1e0344] + WebIO v0.3.4
  [104b5d7c] + WebSockets v1.0.2
  [cc8bc4a8] + Widgets v0.4.2
  [2a0f44e3] + Base64
  [ade2ca70] + Dates
  [8bb1440f] + DelimitedFiles
  [8ba89e20] + Distributed
  [7b1f6079] + FileWatching
  [b77e0a4c] + InteractiveUtils
  [76f85450] + LibGit2
  [8f399da3] + Libdl
  [37e2e46d] + LinearAlgebra
  [56ddb016] + Logging
  [d6f4376e] + Markdown
  [a63ad114] + Mmap
  [44cfe95a] + Pkg
  [de0858da] + Printf
  [3fa0cd96] + REPL
  [9a3f8284] + Random
  [ea8e919c] + SHA
  [9e88b42a] + Serialization
  [1a1011a3] + SharedArrays
  [6462fe0b] + Sockets
  [2f01184e] + SparseArrays
  [10745b16] + Statistics
  [8dfed614] + Test
  [cf7118a7] + UUIDs
  [4ec0a83e] + Unicode
  Building Blink  `~/.julia/packages/Blink/VrROa/deps/build.log`

(tmp) pkg>

What's the next step for this repo? I can send a PR to merge that into master, but should we also cherry-pick it in to the current release? I based that commit off of Blink v0.8.0, so it would be a clean merge if we want to do just a single bug-fix type version bump to v0.8.1. Let me know what you think I should do next!! :)

@NHDaly
Copy link
Collaborator

NHDaly commented Sep 23, 2018

The other simple option is just to merge into master and then cut a new release, but idk if people feel that master is ready for that? I'm not super familiar with the release process here! :)

@pfitzseb
Copy link
Member

I think merging #137 and then tagging a new release should be fine, but then again I don't really use Blink for anything atm. Maybe @rdeits can chime in?

@NHDaly
Copy link
Collaborator

NHDaly commented Sep 24, 2018

Okay, yeah, I think that would be okay.
... The thing that really gives me pause here is that somehow this also seems to work correctly when I request add Blink at master, even though the only difference between v0.8.0 and master is this single change:

09bc951

 # check that <!DOCTYPE html> was declared
-@test  startswith(Blink.maintp.tokens[1][2], "<!DOCTYPE html>\n")
+@test  startswith(Blink.maintp.tokens[1].value, "<!DOCTYPE html>\n")
(tmp) pkg> add Blink#master
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
   Cloning git-repo `https://github.com/JunoLab/Blink.jl.git`
  Updating git-repo `https://github.com/JunoLab/Blink.jl.git`
 Resolving package versions...
 Installed DataStructures ─ v0.14.0
  Updating `Project.toml`
  [ad839575] + Blink v0.8.0+ #master (https://github.com/JunoLab/Blink.jl.git)
  Updating `Manifest.toml`
  [bf4720bc] + AssetRegistry v0.1.0
  [9e28174c] + BinDeps v0.8.10
  [b99e7846] + BinaryProvider v0.5.0
  [ad839575] + Blink v0.8.0+ #master (https://github.com/JunoLab/Blink.jl.git)
  [34da2185] + Compat v1.1.0
  [864edb3b] + DataStructures v0.14.0
  [de31a74c] + FunctionalCollections v0.4.0
  [cd3eb016] + HTTP v0.6.14         # <--------------------
  [9fb69e20] + Hiccup v0.2.2
  [83e8ac13] + IniFile v0.5.0
  [97c1335a] + JSExpr v0.3.1
  [682c06a0] + JSON v0.19.0
  [50d2b5c4] + Lazy v0.13.1
  [1914dd2f] + MacroTools v0.4.4
  [739be429] + MbedTLS v0.6.2
  [ffc61752] + Mustache v0.5.2
  [a975b10e] + Mux v0.5.3
  [510215fc] + Observables v0.2.2
  [bac558e1] + OrderedCollections v1.0.1
  [fa939f87] + Pidfile v1.1.0
  [189a3867] + Reexport v0.2.0
  [ae029012] + Requires v0.5.2
  [30578b45] + URIParser v0.4.0
  [0f1e0344] + WebIO v0.3.4
  [104b5d7c] + WebSockets v1.0.2    # <--------------------
...

So I guess, I don't really understand why it's pulling HTTP v0.7.0 and WebSockets v1.0.0 for Blink v0.8.0, but it's pulling HTTP v0.6.14 and WebSockets v1.0.2 for master. But I guess we can just file this as a mystery, since making changing the REQUIRE file should fix it for us.

So I'll go ahead and merge that into master, and then I'll just go ahead and cut another tag, v0.8.1, right away. I'll merge #137 into master after that but not cut a release, so that we have time to see if that's working well first! :)

@NHDaly
Copy link
Collaborator

NHDaly commented Sep 24, 2018

(#155 merged; v0.8.1 tagged; and METADATA pr opened here: JuliaLang/METADATA.jl#18328)

@NHDaly
Copy link
Collaborator

NHDaly commented Sep 24, 2018

Alright, the tag has been merged into METADATA. I've verified locally that this is all fixed! :)

I'm going to close this now.

@zsunberg If you can, please update Blink, and let us know if everything is working on your end as well! :)

@NHDaly NHDaly closed this as completed Sep 24, 2018
@zsunberg
Copy link
Author

Hi @NHDaly , Thank you so much for fixing this! Works great now!

@NHDaly
Copy link
Collaborator

NHDaly commented Sep 25, 2018

:D I'm glad! :)

@rdeits
Copy link
Collaborator

rdeits commented Sep 25, 2018

Sorry I didn't respond earlier--there's definitely something fishy going on with the version compatibilities of WebSockets and HTTP, but I haven't dug into what it might be. But bounding the WebSockets version seems like a perfectly good solution, and I'm glad it's all working now.

@rdeits
Copy link
Collaborator

rdeits commented Oct 2, 2018

I'm pretty sure I've found the root cause: JuliaWeb/WebSockets.jl#119

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants