Clemapfel / Mousetrap.jl

Finally, a GUI Engine made for Julia

Home Page:https://clemens-cords.com/mousetrap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

first example crashes when starting Julia with multiple threads on apple silicon

ericphanson opened this issue · comments

In [2]: versioninfo()
Julia Version 1.9.2
Commit e4ee485e909 (2023-07-05 09:39 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 4 on 4 virtual cores
Environment:
  JULIA_NUM_THREADS = 4
  JULIA_PKG_SERVER_REGISTRY_PREFERENCE = eager

(@mousetrap) pkg> st
Status `~/.julia/environments/mousetrap/Project.toml`
  [5deeb4b9] mousetrap v0.1.0 `https://github.com/Clemapfel/mousetrap.jl#main`
  [7f2654e2] mousetrap_apple_jll v0.1.0+0 `https://github.com/Clemapfel/mousetrap_apple_jll#main`
  [b6bb2801] mousetrap_linux_jll v0.1.0+0 `https://github.com/Clemapfel/mousetrap_linux_jll#main`
  [1923bf96] mousetrap_windows_jll v0.1.0+0 `https://github.com/Clemapfel/mousetrap_windows_jll#main`

In [4]: using mousetrap

In [5]: main() do app::Application
            window = Window(app)
            set_child!(window, Label("Hello World!"))
            present!(window)
        end

(process:93174): mousetrap.jl-WARNING **: 17:33:46.903: In mousetrap.main: You are running mousetrap from within the REPL. Interactive use of mousetrap is an experimental feature, side-effects may occurr.
Out[5]: Task (runnable) @0x000000010e68a590

In [6]:
(<unknown>:93174): GLib-GIO-CRITICAL **: 17:33:47.332: g_settings_schema_source_lookup: assertion 'source != NULL' failed

(<unknown>:93174): GLib-GIO-CRITICAL **: 17:33:47.332: g_settings_schema_source_lookup: assertion 'source != NULL' failed
2023-08-20 17:33:47.392 julia[93174:85063167] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
*** First throw call stack:
(
)
libc++abi: terminating with uncaught exception of type NSException

[93174] signal (6): Abort trap: 6
in expression starting at none:0
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Allocations: 5301661 (Pool: 5298319; Big: 3342); GC: 8
zsh: abort      julia

If I start Julia with

JULIA_NUM_THREADS=1 julia

then the example works, although it doesn't render as nicely as in the README screenshot.
Screen Shot 2023-08-20 at 17 35 47

Thank you, could you run the following code and tell me if it still crashes?

using mousetrap
app = Application("issue.test")
connect_signal_activate!(app) do app::Application
    window = Window(app)
    set_child!(window, Label("Test"))
    present!(window)
end
run!(app)

I will also try to reproduce this on my end

Thank you, could you run the following code and tell me if it still crashes?

This doesn't crash. No window pops up though. (BTW: I added a close-paren to the line set_child!(window, Label("Test"))

Yes thank you, I typo'd there, also I forgot to add run!, this is the correct code, I also edited the original message.

using mousetrap
app = Application("issue.test")
connect_signal_activate!(app) do app::Application
    window = Window(app)
    set_child!(window, Label("Test"))
    present!(window)
end
run!(app)

Which should open a window.

Does this still crash for you? I apologize for the typos, I shouldn't be answering issue on my phone.

That works! It opens a window and does not crash.
Screen Shot 2023-08-22 at 00 47 53

Okay thank you, I'm pretty sure usage of Threads.Task here is causing this then. I'll have a PR ready as soon as possible.

Until then you can just use that code snippet instead of main. Thank you for helping out!