humbleui

michael zhou 2024-02-28T08:56:24.101919Z

I used the clj -T:build native command to generate the humble-outliner native application, but when running it, the window does not appear. Has anyone encountered this issue before? Thank you.

Niki 2024-02-29T16:28:53.839619Z

Worked for me, too! Amazing!

2024-02-28T12:49:41.840489Z

Could you try the instructions in https://github.com/dundalek/humble-graal to see if running uber jar with java works? Then we will know if it is something with graal or if the problem is somewhere else.

2024-02-28T12:53:24.732699Z

another suggestion would be re-running tracing for the JNI config: https://github.com/dundalek/humble-graal?tab=readme-ov-file#jni-config I ran it only on Linux, it might be possible there are additional classes involved on Mac.

michael zhou 2024-02-28T13:16:52.220039Z

Thanks. uber jar works. I recollect JNI config. Still native humble doesn't show the window. Don't know why.

2024-02-28T14:03:27.958479Z

the strange thing it does not print any errors, so it is hard to debug if you feel like diving a bit deeper you could try to compile the skija example which exercises the underlying libraries JWM+Skija. if that does not work then the problem is with one of these (likely JWM since it does not even shows a window). If it does work, then there is likely something going on in HumbleUI initialization code.

2024-02-28T17:27:14.120439Z

I got curious so I rented a mac machine for debugging. 🙂 I was able to run the graal-compiled skija example, which means the issue is likely not in native libs, but in the clojure code of humbleui, so I am hopeful I will be able to pinpoint it down.

2024-02-28T20:14:13.795109Z

I was able to figure it out, the ui/start-app! starts a new thread (using future) which does not seem to work in graal for some reason. When running the app on a main thread it works. I pushed an update, please give it a try. In practice one would probably want to run it in seprate thread in dev so that REPL is not blocked and then only run it on main thread for release.

2024-02-28T20:14:47.356759Z

Graal-compiled HumbleUI running on M1:

❤️ 4
7
michael zhou 2024-02-29T04:56:38.765129Z

@kloud Thanks. It works.

🎉 2
roklenarcic 2024-03-03T14:53:04.852339Z

What’s the problem with GraalVM and threads?

Niki 2024-03-03T20:32:33.543049Z

macOS requires UI stuff to happen on first thread. On normal JVM, we do a little bit of magic to make it happen https://github.com/HumbleUI/JWM/blob/a04867c5f45b126caafe9abccd9ecd00d3bc516f/macos/cc/App.mm#L48-L62 Maybe this trick doesn’s work in GraalVM? I haven’t looked into it, just one possible caveat

2024-03-03T21:08:13.195419Z

That explains a lot, so what seems to happen is that when humbleui is running on another thread it dispatches UI calls to run on the main thread via a queue. But for some reason these calls don't get executed on the other end when graal-compiled.

2024-03-03T21:08:32.541679Z

The remaining unknown is why graal does that, but that's getting pretty deep. If I had to guess perhaps given things happen in the native land then graal is unable to analyze and optimizes things away.

Niki 2024-03-03T21:11:57.245199Z

I’m not sure how it works in JVM, either. For some reason first thread is still free to be taken over after JVM starts?

Niki 2024-03-03T21:12:18.137589Z

Maybe native graalvm is more straightforward and just uses first thread for main program

2024-03-03T21:45:12.871929Z

Yeah, some mysteries are yet to be understood 🙂 In practice it seem to be good enough for now. It can run on other thread on JVM so that REPL is not blocked during development and for deployment it can be run on the main thread.

roklenarcic 2024-03-03T21:49:52.568069Z

would be interesting to see if thread list and count are the same for a basic graal app and jvm app

michael zhou 2024-02-28T08:57:14.013379Z

I am using Apple M1 Pro

michael zhou 2024-02-28T08:58:22.326149Z

https://github.com/dundalek/humble-outliner

michael zhou 2024-02-28T09:02:44.067869Z