Open TheDrawingCoder-Gamer opened 7 months ago
Changes I needed to make to have it build/run on my (X11) system (i.e. not running any of the actual wayland stuff):
diff --git a/linux/cc/ILayer.hh b/linux/cc/ILayer.hh
index f21346a..5b8ee03 100644
--- a/linux/cc/ILayer.hh
+++ b/linux/cc/ILayer.hh
@@ -15,7 +15,7 @@ public:
virtual void makeCurrentForced();
virtual void setVsyncMode(VSync v) = 0;
virtual void close() = 0;
- virtual void resize(int width, int height);
+ virtual void resize(int width, int height) = 0;
static ILayer* _ourCurrentLayer;
diff --git a/wayland/cc/WindowWayland.cc b/wayland/cc/WindowWayland.cc
index ecbd2a9..ecb7c42 100644
--- a/wayland/cc/WindowWayland.cc
+++ b/wayland/cc/WindowWayland.cc
@@ -100,8 +100,10 @@ bool WindowWayland::init()
wl_surface_listener surfaceListener = {
.enter = WindowWayland::surfaceEnter,
.leave = WindowWayland::surfaceLeave,
+#ifdef HAVE_WAYLAND_1_22
.preferred_buffer_scale = WindowWayland::surfacePreferredBufferScale,
.preferred_buffer_transform = WindowWayland::surfacePreferredBufferTransform
+#endif
};
wl_surface_add_listener(_waylandWindow, &surfaceListener, this);
and here's a bunch of changes, ranging from fixes to hacks to debug utils (i.e. don't blindly copy everything here), to get ./script/run.py
to not crash in Weston (doesn't render anything though):
sorry for the bad commit names. this is what I do when stuff DOESN'T WORK
I have a question about what format the buffer is supposed to be in. I assumed ABGR8888 because of LSBFirst, but is it RGBA8888?
updates ( i guess):
window does now open, but no rendering
skija won't actually bind to LayerGL for some reason??? it can't find the egl context : /. idk what to do there
LayerRaster currently memory leaks every resize because skija is holding on to a pointer. I get crashes when uncommenting out munmap
in ShmPool::close
.
I've made a surprising amount of progress which is nice. I want to get rendering working before I start hooking up the keyboard. Any help would be appreciated bc I don't fully understand C++ (multiple days were taken up because I didn't realize things were freed at the end of scope).
skija won't actually bind to LayerGL for some reason??? it can't find the egl context
Sorry, I wish I could help, but I have no experience with Wayland
ok here's some digging I've done on the GL issue - within Java_io_github_humbleui_jwm_LayerGL__1nAttach
→ LayerGL::attach
→ LayerGL::makeCurrentForced
→ eglMakeCurrent
, some address is set to 1
, which then Java_io_github_humbleui_skija_DirectContext__1nMakeGL
→ ... → GrGLMakeGLXInterface
→ glXGetCurrentContext
later doesn't like. My attempts at searching haven't ended up conclusive, but I think the "X" in "GLX" stands for X11, and thus shouldn't be used on Wayland (and/or be mixed with egl)? (I don't have much clue what I'm looking at, I'm primarily just having fun with debugging under https://rr-project.org/)
I am not using glx though. I'm using egl, which SHOULD work on wayland.
OH, you mean in skija. Yeah that is likely an upstream issue.
#0 0x00007f22c3e5c9fe in glXGetCurrentContext () from /lib/x86_64-linux-gnu/libGLX.so.0
#1 0x00007f228af92132 in GrGLMakeGLXInterface() () from /tmp/skija_0.116.1_x64/libskija.so
#2 0x00007f228ae93d72 in GrGLMakeNativeInterface() () from /tmp/skija_0.116.1_x64/libskija.so
#3 0x00007f228aafe498 in GrGLGpu::Make(sk_sp<GrGLInterface const>, GrContextOptions const&, GrDirectContext*) () from /tmp/skija_0.116.1_x64/libskija.so
#4 0x00007f228a9e9a45 in GrDirectContext::MakeGL(sk_sp<GrGLInterface const>, GrContextOptions const&) () from /tmp/skija_0.116.1_x64/libskija.so
#5 0x00007f228a9e9ed7 in GrDirectContext::MakeGL() () from /tmp/skija_0.116.1_x64/libskija.so
#6 0x00007f228a4c2920 in Java_io_github_humbleui_skija_DirectContext__1nMakeGL () from /tmp/skija_0.116.1_x64/libskija.so
#7 0x00007f22b4356b11 in ?? ()
#8 0x00007f22cad16e10 in ?? ()
#9 0x0000000000000000 in ?? ()
the full gdb stacktrace of the fail fwiw
oh, is skia in skija built with X11/GLX hard-coded? skia does have a thing that'd supposedly use EGL for GrGLMakeNativeInterface
, but that's not present in the skija build afaict
perhaps a skia_use_egl=true
in like here or something?
gonna try building that, probably gonna take a while though
X11 could also be possibly rewritten to use EGL too - it would ensure that all linux targets would work with EGL.
(or we could just add an if statement to the constructor of LayerGLSkija : ) )
Got a skia build with that to load (ended up ln -s
ing SkiaBuild's output unzipped to Skija's platform/Skia-m116-f44dbc40d8-linux-Release-x64/
and doing a clean rebuild); gives this now:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/skija_369211854708109/libskija.so: /tmp/skija_369211854708109/libskija.so: undefined symbol: eglQueryString
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:331)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:197)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:139)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2404)
at java.base/java.lang.Runtime.load0(Runtime.java:785)
at java.base/java.lang.System.load(System.java:2011)
at io.github.humbleui.skija.impl.Library._loadFromFile(Library.java:147)
at io.github.humbleui.skija.impl.Library.load(Library.java:122)
at io.github.humbleui.skija.impl.Library.staticLoad(Library.java:20)
at io.github.humbleui.skija.Font.<clinit>(Font.java:9)
at io.github.humbleui.jwm.examples.Example.<clinit>(Example.java:18)
should be easy enough to fix once I find where
and with a
diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt
index 6b352fe..23afd7e 100644
--- a/platform/CMakeLists.txt
+++ b/platform/CMakeLists.txt
@@ -84,4 +84,4 @@ endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(FindSkia)
-target_link_libraries(skija skottie sksg svg skparagraph skshaper skunicode skresources skia ${FREETYPE_LIBRARIES} ${HARFBUZZ_LIBRARIES})
+target_link_libraries(skija skottie sksg svg skparagraph skshaper skunicode skresources skia EGL ${FREETYPE_LIBRARIES} ${HARFBUZZ_LIBRARIES})
in Skija, JWM now doesn't crash with LayerGLSkija
! Doesn't show any window though; presumably just unfinished?
(here's a Skija linux x64 jar file of that; usable for JWM's example thing with ./script/run.py --skija-platform-jar /path/to/that/target/skija-linux-x64-0.0.0-SNAPSHOT.jar
)
Seems with this EGL build JWM & Skija still work on X11 with no extra changes? So that's nice (assuming that's correct and not me having forgotten to do something)
Yeah just unfinished - needs more work. Will make a PR to skia build and skija to include EGL.
You did test X11, correct? this doesn't break X11 if I change skija?
yeah, said that in my last comment; running the exact same command works both in my native X11, and within Weston, both using LayerGLSkija
(with X11 properly rendering things as usual, and Weston quietly doing nothing). There could be some implications I'm not aware of, but ¯\_(ツ)_/¯
I think I will have to add an if statement in JWM and add an "MakeEGL" thing for it, as MakeGL
is currently platform specific (thus can't really differ on different installs of linux).
While the window is infact showing, it's incapable of actually rendering anything. It can't actually make the DirectContext (it errors out, because GrDirectContext::MakeGL().release()
returns nullptr
only on wayland : /)
Huh? For me, GrDirectContext::MakeGL().release()
gave nullptr
before the SkiaBuild
change, but the entire purpose of the Skia change was to make GrDirectContext::MakeGL()
work, and it does appear to for me; i.e. adjusting Skija's DirectContext::makeGL
to
public static DirectContext makeGL() {
Stats.onNativeCall();
System.out.println("pre-_nMakeGL in Java");
long ptr = _nMakeGL();
System.out.println("post-_nMakeGL in Java: got "+ptr);
new Exception().printStackTrace();
return new DirectContext(ptr);
}
results in logging of
pre-_nMakeGL in Java
post-_nMakeGL in Java: got 140025466978336
java.lang.Exception
at io.github.humbleui.skija.DirectContext.makeGL(DirectContext.java:15)
at io.github.humbleui.jwm.skija.LayerGLSkija.frame(LayerGLSkija.java:27)
at io.github.humbleui.jwm.Window.accept(Window.java:412)
at io.github.humbleui.jwm.Window.accept(Window.java:427)
at io.github.humbleui.jwm.Window.accept(Window.java:425)
at io.github.humbleui.jwm.Window.setLayer(Window.java:66)
at io.github.humbleui.jwm.examples.PanelRendering.changeLayer(PanelRendering.java:57)
at io.github.humbleui.jwm.examples.PanelRendering.<init>(PanelRendering.java:44)
at io.github.humbleui.jwm.examples.Example.<init>(Example.java:51)
at io.github.humbleui.jwm.examples.Example.lambda$main$0(Example.java:229)
at io.github.humbleui.jwm.App.lambda$start$1(App.java:35)
at io.github.humbleui.jwm.App._nStart(Native Method)
at io.github.humbleui.jwm.App.start(App.java:28)
at io.github.humbleui.jwm.examples.Example.main(Example.java:228)
pre-_nMakeGL in Java
post-_nMakeGL in Java: got 140025466978336
java.lang.Exception
at io.github.humbleui.skija.DirectContext.makeGL(DirectContext.java:15)
at io.github.humbleui.jwm.skija.LayerGLSkija.frame(LayerGLSkija.java:27)
at io.github.humbleui.jwm.Window.accept(Window.java:412)
at io.github.humbleui.jwm.Window.accept(Window.java:427)
at io.github.humbleui.jwm.Window.accept(Window.java:425)
at io.github.humbleui.jwm.Window.setVisible(Window.java:280)
at io.github.humbleui.jwm.WindowWayland.setVisible(WindowWayland.java:92)
at io.github.humbleui.jwm.examples.Example.<init>(Example.java:88)
at io.github.humbleui.jwm.examples.Example.lambda$main$0(Example.java:229)
at io.github.humbleui.jwm.App.lambda$start$1(App.java:35)
at io.github.humbleui.jwm.App._nStart(Native Method)
at io.github.humbleui.jwm.App.start(App.java:28)
at io.github.humbleui.jwm.examples.Example.main(Example.java:228)
hm, I must have messed up my local build. Did you do anything other than just add skia_use_egl
?
Something must be different in our environments : / Adding that same code it still returns null under wayland, but works fine under x11.
What I'm more worried about at the moment is that Raster isn't showing anything.
this is my SkiaBuild diff (the compiler diffs are just because I don't have gcc-9 installed; shouldn't affect anything), and this in Skija (all that matters is the platform/CMakeLists.txt
; ignore the syscall(-1)
, I abuse that as a "checkpoint" for debugging).
After doing SkiaBuild script/checkout.py --version m116-f44dbc40d8
, script/build.py
, and script/archive.py
, I unzipped the Skia-m116-f44dbc40d8-linux-Release-x64.zip
to a folder in Skija under platform/Skia-m116-f44dbc40d8-linux-Release-x64
, removing what was there before. Then within Skija I ran ./script/clean.py
and then ./script/build.py && ./script/package_platform.py
and then for JWM's --skija-platform-jar
used the output in Skija's target/skija-linux-x64-0.0.0-SNAPSHOT.jar
.
In Weston I do have raster rendering the window (although it is somewhat broken, only redrawing whenever the window is unfocused & refocused).
Wayland also either forces you to draw window frames, or use a library like libdecor to ask the compositor nicely to draw it for you. I opted to use libdecor, but it crashes on mouse hover under weston (swaywm doesn't crash, but I assume that's because it doesn't actually draw anything)
It seems to be an error in JNI from mouse movement, more likely due to dispatching, which is kind of odd considering OTHER dispatches work?
here's a random stacktrace of a random segfault from making PanelRendering switch from raster to GL on a mouse button press (doesn't error always, sometimes it does manage to switch from raster to rendering nothing on GL; this is before the libdecor change):
#0 0x00007f583a3efe43 in jwm::Window::dispatch(_jobject*) () from /mnt/linux2/git/jwm-wayland/target/classes/libjwm_x64_wayland.so
#1 0x00007f583a3f27c6 in jwm::WindowManagerWayland::mouseUpdate(jwm::WindowWayland*, unsigned int, unsigned int, unsigned int) () from /mnt/linux2/git/jwm-wayland/target/classes/libjwm_x64_wayland.so
#2 0x00007f583a327e2e in ?? () from /lib/x86_64-linux-gnu/libffi.so.8
#3 0x00007f583a324493 in ?? () from /lib/x86_64-linux-gnu/libffi.so.8
#4 0x00007f583a632ad0 in ?? () from /lib/x86_64-linux-gnu/libwayland-client.so.0
#5 0x00007f583a633243 in ?? () from /lib/x86_64-linux-gnu/libwayland-client.so.0
#6 0x00007f583a63343c in wl_display_dispatch_queue_pending () from /lib/x86_64-linux-gnu/libwayland-client.so.0
#7 0x00007f583a3f21dd in jwm::WindowManagerWayland::runLoop() () from /mnt/linux2/git/jwm-wayland/target/classes/libjwm_x64_wayland.so
not a worry for now, but noting regardless (error is from myWindow
being null, presumably pointerHandleMotion
of the old surface running after we've switched to the new one?)
will look at what the libdecor change looks like
edit: oh that's handled in the latest commit!
ok with that last commit GL crashes with my "OH NO SAD", and raster doesn't render anything
It breaking may have been caused by me switching from glext
api to glplatform
. Unsure why that breaks stuff
edit: nvm, doesn't change anything. how peculiar
with this, GL not crashing is restored:
diff --git a/wayland/cc/LayerGLWayland.cc b/wayland/cc/LayerGLWayland.cc
index 27f6c93..abc8aa9 100644
--- a/wayland/cc/LayerGLWayland.cc
+++ b/wayland/cc/LayerGLWayland.cc
@@ -73,6 +73,7 @@ namespace jwm {
throw std::runtime_error("Couldn't make context");
}
}
+ makeCurrentForced();
}
:o while undoing random parts of your changes, I now have a GL rendering the window in weston, and with proper refreshing too unlike raster! (those undoed changes include undoing all of libdecor though)
Unsure how makeCurrentForced
works considering that you should have to have a surface first
For me the whole compositor must lose focus and be refocused for window to be visible. For SwayWM i am doing this by switching ttys, so something god awful is going on
Adding a libdecor_dispatch(_windowManager.decorCtx, -1);
right after libdecor_decorate
does Something (and results in some segfaulting too; looking into that)
Try adding libdecor_frame_map(_frame)
at the end of show
, I'm not segfaulting with that at the end
and move the dispatch to after the map
nvm, pointer will still crash. Again, only in weston?
I don't think I actually commited the change where I commented out the pointer listener, but you seem to be getting something, which is confusing.
Is it possible it doesn't like WHERE I'm calling dispatch
from? I don't really understand the difference
I'm getting a decorated window in Weston, but it only appears after changing the weston window size. And it's of course still segfaulting. I have a very slight guess that there might be some memory corruption, am investigating
printing fWindow
in jwm::Window::dispatch
does give a different value on the crashing iteration. Honestly I have no clue what's happening (rr is breaking on me repeatedly), but potentially libdecor_decorate
and/or libdecor in general is writing over it for some reason..?
Is it possible it's losing all references for some reason?
the window object? maybe, though the ~Window
isn't called (libdecor specifically messing with it seems unlikely now; xor
ing the this
argument of the data pointers of libdecor_decorate
and wl_surface_add_listener
leads it to still failing)
Layers call jwm::unref
, which removes one reference to it - but idk why this would do anything, unless close was being called multiple times
????? the WHOLE this? wouldn't that extend to WindowWayland
as well?
(ignore me there, I did a stupid)
If libdecor changes the user data on the surface, then YES it would cause issues.
libdecor does in fact not touch the user data pointer in any way other than passing it where it should
It adds listeners though, which also sets userdata. Only for cursor surface though??
ok the issue might be quite simple - the window
derived in pointerHandleMotion
is invalid (added a field of int sanityCheck = 31415926;
in WindowWayland
, and added if (window->sanityCheck != 31415926) { printf("NOT WINDOW\n"); __builtin_trap(); }
in pointerHandleMotion
)
I'll revert to finding in native : /. Bad optimization on my part
Untested (couldn't get javac to work) Highly expect something here to be extremely broken. Would not be surprised if there was an instant segfault. bc it's literally a new platform this touches a LOT of files. Will work on merging