<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Aha! That's the problem: I call notify_*() from my own thread which reads a socket fd from a remote server. <span style="color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">Sounds like the correct way to do this is use</span><span style="color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;"> </span><span style="color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">wl_event_loop_add_fd()
to register the socket, and read from the fd in the callback?</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;"><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">I have some non-input messages that need to remain async from weston's event loop (ex. some setup during compositor start), so I did a test by keeping the <span style="font-family: Calibri, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important">notify_*()
event calls in my thread and then "dispatch" the event loop by sending a signal over a pipe which I registered with <span style="font-family: Calibri, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important">wl_event_loop_add_fd().
This appears to be working! I just want to make sure there's no obvious problems/race-conditions that come to mind with calling <span style="font-family: Calibri, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important">notify_*()
asynchronously?</span></span></span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;"><span style="font-family: Calibri, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important"><span style="font-family: Calibri, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important"><span style="font-family: Calibri, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important"><br>
</span></span></span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;"><span style="font-family: Calibri, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important"><span style="font-family: Calibri, Helvetica, sans-serif; background-color: rgb(255, 255, 255); display: inline !important">And
thanks for all the help!! </span></span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0);">
<hr tabindex="-1" style="display:inline-block; width:98%;">
<b>From:</b> Pekka Paalanen<br>
<b>Sent:</b> Thursday, February 13, 2020 4:33 AM<br>
<b>To:</b> Josh Simonot<br>
<b>Cc:</b> wayland-devel@lists.freedesktop.org<br>
<b>Subject:</b> Re: repaint after notify_button() ?
<div><br>
</div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On Wed, 12 Feb 2020 17:22:05 +0000<br>
Josh Simonot <jsimonot@live.ca> wrote:<br>
<br>
> calling wl_event_loop_dispatch() is not a working solution: keeps<br>
> tripping over a few different assertions causing crash, and doesn't<br>
> seem to dispatch key events.<br>
> <br>
> I've seen:<br>
> - page_flip_handler: Assertion `output->page_flip_pending' failed.<br>
> - weston_output_finish_frame: Assertion `output->repaint_status ==<br>
> REPAINT_AWAITING_COMPLETION' failed.<br>
<br>
Hi,<br>
<br>
you seem to be confusing some libwayland-server and libwayland-client<br>
APIs (wl_display_dispatch_pending()). Both unfortunately have a 'struct<br>
wl_display' type, but the two types are distinct and totally<br>
incompatible. So make sure to use only server API with the server-side<br>
library and objects.<br>
<br>
There should be no need to force-wake the event loop at all. It wakes<br>
up automatically from epoll_wait() when any file descriptor (including<br>
client sockets, timers and POSIX signals) registered with it is<br>
readable (or sometimes writable, which ever is appropriate).<br>
<br>
Before sleeping in epoll, it also flushes out all pending messages out<br>
to clients.<br>
<br>
Dispatching an event loop from random places at random times is a bad<br>
idea. Especially if it happens during dispatch, which may well mess<br>
things up: bad message ordering and maybe memory corruption. This means<br>
there is really no place in Weston where you could actually<br>
force-dispatch anything, everything already happens inside dispatch<br>
calls except during compositor start and shutdown.<br>
<br>
You say the notify_*() functions are called in time. Next thing is to<br>
check if the related events are sent out in time, and that you can<br>
check with WAYLAND_DEBUG=server or using 'weston-debug proto' (needs<br>
to start weston with --debug). If those are delayed, then we are sure<br>
the issue is in the compositor. If those are in time, then the issue<br>
cannot be in the compositor.<br>
<br>
>From what call chain to you call the notify_*() functions? An fd event<br>
source of your own? Idle source? Timer source? Or simply from some<br>
arbitrary function already in the DRM-backend?<br>
<br>
<br>
Thanks,<br>
pq<br>
</div>
</span></font></div>
</body>
</html>