[Wayland-bugs] [Bug 91750] Wayland may have interface bug when multi-threads programing.
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Wed Aug 26 23:28:43 PDT 2015
https://bugs.freedesktop.org/show_bug.cgi?id=91750
--- Comment #9 from Yujie Shen <syjman at gmail.com> ---
(In reply to Jonas Ådahl from comment #8)
> (In reply to Yujie Shen from comment #7)
> > (In reply to Jonas Ådahl from comment #6)
> > > Yujie: as indirectly stated by Pekka, my example was incomplete. You would
> > > also need to dispatch pending events before the
> > > wl_display_prepare_read(display) call. This makes it, ignoring error
> > > handling, more or less:
> > >
> > > wl_surface_attach();
> > > while (wl_display_prepare_read_queue(display, queue) < 0)
> > > wl_display_dispatch_queue_pending(display, queue);
> > > window->callback = wl_surface_frame(window->surface);
> > > wl_proxy_set_queue(window->callback,queue2);
> > > wl_callback_add_listener(window->callback, &frame_listener, window);
> > > wl_display_cancel_read(display);
> > > wl_surface_commit(window->surface);
> > >
> > > This has the side effect that events already in the queue will be always
> > > dispatched before the frame is requested. This may have unwanted effects, so
> > > please consider whether this is Ok in your architecture. If it is not, you
> > > need to make sure that the above code is done after all events on the queue
> > > has been dispatched.
> >
> > Thanks for your kindly help.
> > By adding
> > >while (wl_display_prepare_read_queue(display, queue2) < 0)
> > > wl_display_dispatch_queue_pending(display, queue2);
> > >wl_surface_commit(window->surface);
> > it works in my case.
> > but, I still don't understand why it requires the wl_event_queue to be
> > empty??
> > I'm trying to summary the restrictions of wayland when multi-thread
> > programming.
> > May I know if you have any idea about it.
>
> It is a requirement by wl_display_prepare_read_queue() that to succeed the
> queue has to be empty and it needs to succeed in order to block the other
> threads from dispatching. You should put it before wl_surface_frame()
> though, because it is between wl_surface_frame() and wl_proxy_set_queue()
> the race can happen, and don't forget to call wl_display_cancel_read().
>
> Earlier today I wrote a summary about the known threading issues in the API.
> Please see bug 91769.
Thanks.
I know it is a requirement by wl_display_prepare_read_queue() .
I mean why it is designed as that, only the queue is empty then it block the
other
threads from dispatching. It seems that wl_display_prepare_read_queue can also
be designed as it still can block other threads from dispatching when the queue
is not empty.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-bugs/attachments/20150827/95f02986/attachment.html>
More information about the wayland-bugs
mailing list