scrgiorgio / Plasm.jl

MIT License
0 stars 0 forks source link

Multiple active Viewer objects #2

Open apaoluzzi opened 7 months ago

apaoluzzi commented 7 months ago

Il would be of greater benefit to Plasm users to have more that one active Viewer objects.

Currently, only one Viewer object (1) gets control of execution, and (2) programs cannot continue until it is closed and (3) the control returns to Julia's Main process.

It would be great if (in some future release) Plasm.jl multiprocessing could open, interact, and close more that one Viewer windows, possibly under the control of Julia REPL on the terminal.

Great benefits would arise both for the julia software developer (e.g. in debug) and the designer (engineer, architect, etc.) enjoying Plasm.jl

scrgiorgio commented 2 days ago

Added another parameter use_thread to allow running multiple viewers in parallel.

To enable threading you MUST run julia using:

julia --project=. --threads=auto 

An example using REPL:

using Plasm
VIEW(CUBOID([1,1,1]), use_thread=true)
VIEWCOMPLEX(lar, use_thread=true)

@apaoluzzi please check and close the issus

apaoluzzi commented 2 days ago

The new version die on macOS Sequoia v15.0.1

The terminal script follow:

(base) ✔ ~/github.com/scrgiorgio/Plasm.jl [main|⚑ 4] 
11:32 $ julia --project=. --threads=auto 
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.4 (2024-06-04)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Plasm

julia> VIEW(CUBOID([1,1,1]), use_thread=true)
Creating Window use_thread=true
Task (runnable) @0x000000016322c550

julia> VIEWCOMPLEX(lar, use_thread=true)*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow should only be instantiated on the main thread!'
*** First throw call stack:
(
)
libc++abi: terminating due to uncaught exception of type NSException

[23741] signal (6): Abort trap: 6
in expression starting at none:0
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
pthread_kill at /usr/lib/system/libsystem_pthread.dylib (unknown line)
abort at /usr/lib/system/libsystem_c.dylib (unknown line)
abort_message at /usr/lib/libc++abi.dylib (unknown line)
_ZL28demangling_terminate_handlerv at /usr/lib/libc++abi.dylib (unknown line)
_ZL15_objc_terminatev at /usr/lib/libobjc.A.dylib (unknown line)
_ZSt11__terminatePFvvE at /usr/lib/libc++abi.dylib (unknown line)
_ZN10__cxxabiv1L12failed_throwEPNS_15__cxa_exceptionE at /usr/lib/libc++abi.dylib (unknown line)
__cxa_throw at /usr/lib/libc++abi.dylib (unknown line)
objc_exception_throw at /usr/lib/libobjc.A.dylib (unknown line)
-[NSException raise] at /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (unknown line)
-[NSWindow _initContent:styleMask:backing:defer:contentView:] at /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (unknown line)
-[NSWindow initWithContentRect:styleMask:backing:defer:] at /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (unknown line)
_glfwCreateWindowCocoa at /Users/paoluzzi/.julia/artifacts/893d47a4a45d1849a679fcda9ff668be0d8d3ee7/lib/libglfw.3.4.dylib (unknown line)
glfwCreateWindow at /Users/paoluzzi/.julia/artifacts/893d47a4a45d1849a679fcda9ff668be0d8d3ee7/lib/libglfw.3.4.dylib (unknown line)
CreateWindow at /Users/paoluzzi/.julia/packages/GLFW/wmoTL/src/glfw3.jl:571
CreateWindow at /Users/paoluzzi/.julia/packages/GLFW/wmoTL/src/glfw3.jl:571 [inlined]
CreateWindow at /Users/paoluzzi/.julia/packages/GLFW/wmoTL/src/glfw3.jl:571 [inlined]
#run_viewer_in_current_thread#57 at /Users/paoluzzi/github.com/scrgiorgio/Plasm.jl/src/viewer.glfw.jl:939
run_viewer_in_current_thread at /Users/paoluzzi/github.com/scrgiorgio/Plasm.jl/src/viewer.glfw.jl:887 [inlined]
#69 at /Users/paoluzzi/github.com/scrgiorgio/Plasm.jl/src/viewer.glfw.jl:997
unknown function (ip: 0x103884dbc)
_jl_invoke at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-grannysmith-C07ZM05NJYVY.0/build/default-grannysmith-C07ZM05NJYVY-0/julialang/julia-release-1-dot-10/src/gf.c:0 [inlined]
ijl_apply_generic at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-grannysmith-C07ZM05NJYVY.0/build/default-grannysmith-C07ZM05NJYVY-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-grannysmith-C07ZM05NJYVY.0/build/default-grannysmith-C07ZM05NJYVY-0/julialang/julia-release-1-dot-10/src/./julia.h:1982 [inlined]
start_task at /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-grannysmith-C07ZM05NJYVY.0/build/default-grannysmith-C07ZM05NJYVY-0/julialang/julia-release-1-dot-10/src/task.c:1238
Allocations: 18672286 (Pool: 18643691; Big: 28595); GC: 18
Abort trap: 6
(base) ✘-ABRT ~/github.com/scrgiorgio/Plasm.jl [main|⚑ 4] 
11:33 $ 
scrgiorgio commented 1 day ago

it's related to MacOS. See: https://github.com/JuliaGL/GLFW.jl/issues/233 we have the latest version so we cannot fix it right now.