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

Can IJulia Jupyter/Pluto run on Linux without JULIA_COPY_STACKS=1? #145

Open
roflmaostc opened this issue May 14, 2021 · 6 comments
Open

Comments

@roflmaostc
Copy link

Hey,

in the REPL it is possible to run a JavaCall dependent library (like View5D) without JULIA_COPY_STACKS=1.
In IJulia or Pluto it is not:

JavaCall.JavaCallError("Either the environmental variable JULIA_COPY_STACKS must be 1 OR JavaCall must be used on the root Task.")

Stacktrace:
 [1] assertroottask_or_goodenv
   @ ~/.julia/packages/JavaCall/tjlYt/src/jvm.jl:236 [inlined]
 [2] _init(opts::Vector{String})
   @ JavaCall ~/.julia/packages/JavaCall/tjlYt/src/jvm.jl:285
 [3] init()
   @ JavaCall ~/.julia/packages/JavaCall/tjlYt/src/jvm.jl:277
 [4] view5d(data::Matrix{Float64}, viewer::Nothing; gamma::Nothing, mode::DisplayMode, element::Int64, time::Int64, show_phase::Bool, keep_zero::Bool, name::Nothing, title::Nothing, properties::Nothing)
   @ View5D ~/.julia/packages/View5D/cKswI/src/View5D.jl:1023
 [5] view5d (repeats 2 times)
   @ ~/.julia/packages/View5D/cKswI/src/View5D.jl:1021 [inlined]
 [6] top-level scope
   @ In[5]:1
 [7] eval
   @ ./boot.jl:360 [inlined]
 [8] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1094

Some libraries, like FFTW.jl, crash when JULIA_COPY_STACKS=1 which is unfortunately a deal breaker for my applications.

Can we resolve this situation?

Thanks,

Felix

@roflmaostc roflmaostc changed the title Can IJulia Jupyter/Pluto run on Linux without JULIA_COPY_STACKS=1? Can IJulia Jupyter/Pluto run on Linux without JULIA_COPY_STACKS=1? May 14, 2021
@mkitti
Copy link
Member

mkitti commented May 14, 2021

The only other way is for JavaCall to run on the root Task. You can check if you are on the root task by comparing Base.roottask with Base.current_task():

julia> Base.roottask == Base.current_task()
true

If you can first start JavaCall on the root task, then you can use something like https://github.com/mkitti/TaskWorkers.jl to run a server task on the root Task to talk to Java.

Another way to do that is to have two Julia processes. One uses JavaCall while the other runs the notebook. You invoke Java commands by communicating between the two Julia proceses using something like RemoteChannel. At this point though, maybe using something like ZeroMQ via ZMQ.jl makes more sense.

@mkitti
Copy link
Member

mkitti commented May 14, 2021

Looking at IJulia, what you probably would need to do is create a custom kernel.jl which loads JavaCall and TaskWorkers, and then runs @async IJulia.waitloop() just before starting the worker.

https://github.com/JuliaLang/IJulia.jl/blob/cc2a9bf61a2515596b177339f9a3514de8c38573/src/kernel.jl

@roflmaostc
Copy link
Author

Hm looks tricky 😕

But would it be possible that View5D could manage the TaskWorkers.jl stuff to ensure that when it is called from within Pluto it calls the root task?

@mkitti
Copy link
Member

mkitti commented May 17, 2021 via email

@mkitti
Copy link
Member

mkitti commented May 26, 2021

I'm checking in to see if you made any progress on this.

@roflmaostc
Copy link
Author

roflmaostc commented May 27, 2021

Sorry, I haven't really tried to solve this.

Maybe @RainerHeintzmann wants to tackle this 😄

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

No branches or pull requests

2 participants