[wpe-webkit] Using WebKitWPE in an existing GMainLoop/Wayland render loop

Ryan Walklin ryan at testtoast.com
Sat Apr 20 20:50:15 PDT 2019

Hi all,

I'm trying to integrate WebKitWPE into an existing Wayland App using EGL for rendering (written in Swift on Fedora 30). I'm using a CFRunLoop as my event loop, driving a GMainLoop event loop using code similar to https://gitlab.gnome.org/GNOME/gtk/blob/master/gdk/quartz/gdkeventloop-quartz.c. (In fact essentially this code ported to Swift). I then have a Wayland fd GSource similar to https://gitlab.gnome.org/GNOME/gtk/blob/master/gdk/wayland/gdkeventsource.c (again largely ported from here to Swift). 

This works well and I am able to create a window and run a simple EGL renderer (essentially just clearing the screen and calling eglSwapBuffers() as per https://github.com/emersion/hello-wayland/blob/opengl-render-loop/main.c). 

However when I try to integrate WebKitWPE, I am able to create the backend, context and view objects as Cog does, however when my event loop then runs, I get a crash inside wayland-server:

[21/Apr/2019:03:48:02 +0000] [INFO] [WebKitWPEBackend.swift:52 init(display:)] Initialised WPE WebKit view for 0x0000555555666630
[21/Apr/2019:03:48:02 +0000] [DEBUG] [EventLoop.swift:212 runLoopEntry()] EventLoop: Beginning tracking run loop activity
[21/Apr/2019:03:48:02 +0000] [DEBUG] [WaylandWSIWindow.swift:164 xdgToplevelHandleConfigure(data:xdg_toplevel:width:height:states:)] Window size 786x523
[21/Apr/2019:03:48:02 +0000] [DEBUG] [WaylandWSIWindow.swift:303 surfaceOutputEnter(data:surface:output:)] Entered output
Process 10913 stopped
* thread #1, name = 'Spitfire', stop reason = signal SIGSEGV: address access protected (fault address: 0x555555d8ac18)
    frame #0: 0x0000555555d8ac18
->  0x555555d8ac18: addb   %al, (%rax)
    0x555555d8ac1a: addb   %al, (%rax)
    0x555555d8ac1c: addb   %al, (%rax)
    0x555555d8ac1e: addb   %al, (%rax)
Target 0: (Spitfire) stopped.
(lldb) bt
* thread #1, name = 'Spitfire', stop reason = signal SIGSEGV: address access protected (fault address: 0x555555d8ac18)
  * frame #0: 0x0000555555d8ac18
    frame #1: 0x00007ffff0c64b28 libffi.so.6`.annobin_ffi64.c_end at unix64.S:76
    frame #2: 0x00007ffff0c64339 libffi.so.6`ffi_call at ffi64.c:525:3
    frame #3: 0x00007fffedd5f3b3 libwayland-server.so.0`wl_closure_invoke(closure=0x0000555555d0bfe0, flags=2, target=0x0000555555d37f80, opcode=6, data=0x0000555555d96f90) at connection.c:1014:2
    frame #4: 0x00007fffedd59309 libwayland-server.so.0`wl_client_connection_data(fd=14, mask=1, data=0x0000555555d96f90) at wayland-server.c:429:4
    frame #5: 0x00007fffedd5c568 libwayland-server.so.0`wl_event_source_fd_dispatch(source=0x0000555555d06e90, ep=0x00007fffffffd1a0) at event-loop.c:95:9
    frame #6: 0x00007fffedd5cf0a libwayland-server.so.0`wl_event_loop_dispatch(loop=0x0000555555d7f740, timeout=-1) at event-loop.c:641:4
    frame #7: 0x00007ffff3481b8e libWPEBackend-fdo-1.0.so.1`WS::Source::<lambda(GSource*, GSourceFunc, gpointer)>::_FUN(GSource *, GSourceFunc, gpointer) at ws.cpp:111:35
    frame #8: 0x00007ffff3481b78 libWPEBackend-fdo-1.0.so.1`WS::Source::<lambda(GSource*, GSourceFunc, gpointer)>::_FUN((null)=0x0000555555d7f0f0, (null)=<unavailable>, (null)=<unavailable>) at ws.cpp:120
    frame #9: 0x00007ffff6e6cfd0 libglib-2.0.so.0`g_main_context_dispatch + 352
    frame #10: 0x000055555558b0d4 Spitfire`EventLoop.runLoopAfterWaiting(self=<unavailable>) at EventLoop.swift:354:13
    frame #11: 0x000055555558981a Spitfire`EventLoop.runLoopCallback(activity=64, self=<unavailable>) at EventLoop.swift:201:13
    frame #12: 0x00005555555891f0 Spitfire`closure #1 in variable initialization expression of EventLoop.runLoopObserverCallback(observer=0x0000555555d8aa00, activity=64, data=(_rawValue = 0x00005555555f2bc0 -> 0x00005555555e30f8 full type metadata for Harness.(EventLoop in _CFA4502A75382A07B34B2FC6679BE4E0) + 16)) at EventLoop.swift:174:19
    frame #13: 0x00005555555892be Spitfire`@objc closure #1 in variable initialization expression of EventLoop.runLoopObserverCallback at <compiler-generated>:0
    frame #14: 0x00007ffff75f9ac4 libFoundation.so`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
    frame #15: 0x00007ffff75f5c1b libFoundation.so`__CFRunLoopDoObservers + 379
    frame #16: 0x00007ffff75f623a libFoundation.so`__CFRunLoopRun + 1434
    frame #17: 0x00007ffff75f5a09 libFoundation.so`CFRunLoopRunSpecific + 473
    frame #18: 0x00007ffff74ddf3e libFoundation.so`Foundation.RunLoop.run() -> () + 126
    frame #19: 0x0000555555588fca Spitfire`EventLoop.run(self=<unavailable>) at EventLoop.swift:161:16
    frame #20: 0x00005555555868c3 Spitfire`eventLoopRun() at EventLoop.swift:34:19
    frame #21: 0x00005555555c12c8 Spitfire`main at main.swift:61:1
    frame #22: 0x00007ffff2db1f33 libc.so.6`.annobin_libc_start.c + 243
    frame #23: 0x000055555556730e Spitfire`.annobin_init.c.hot + 46

I understand WebKitWPE creates its own Wayland event queue and runs it independently, but it seems to be interfering with the main queue somehow. The target a function is being called upon is a wl_surface, which I assume is the one I've already created in my app.

Would appreciate if anyone has any insight!



More information about the webkit-wpe mailing list