GNOME Bugzilla – Bug 749078
[wayland] finer frame control
Last modified: 2015-06-19 09:04:16 UTC
The following patches are meant to fix what bug #747492 and bug #746501 aim.
Created attachment 303043 [details] [review] wayland: decouple wl_buffer from frame This patch takes out the wayland's buffer from the the frame structure. The buffer is queued to wayland and destroyed in the "release" callback. The frame is freed in the surface's "done" callback. In this way a buffer may be leaked but not the whole frame structure. - surface 'done' callback is used to throttle the rendering operation and to unallocate the frame, but not the buffer. - buffer 'release' callback is used to destroy wl_buffer. Original-patch-by: Zhao Halley <halley.zhao@intel.com> * code rebase * kept the the event_queue for buffer's proxy Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Created attachment 303044 [details] [review] wayland: use a counter as sync flag Wayland window has a pointer to the last pushed frame and use it to set the flag for stopping the queue dispatch loop. This may lead to memory leaks, since we are not keeping track of all the queued frames structures. This patch removes the last pushed frame pointer and change the binary flag for an atomic counter, keeping track of number of queued frames and use it for the queue dispatch loop.
Created attachment 303045 [details] [review] wayland: rename frame for last_frame Since frame in the private data means the last frame sent, it would semantically better use last_frame. Also, this patch makes use of g_atomic_pointer_{compare_and_exchange, set}() functions.
Created attachment 303046 [details] [review] wayland: sync() when destroy() Before pushing a the new frame, the render() method calls sync() to flush the pending frames. Nonetheless, the last pushed frames is never sync() leading to a memory leak, also. This patch calls sync() in the destroy() to flush the pending frames before destroying the window.
Created attachment 303047 [details] [review] wayland: wl_display_dispatch_queue() can block forever. wl_display_dispatch_queue() might prevent the pipeline from shutting down. This can happen e.g. if the wayland compositor exits while the pipeline is running. This patch replaces it with these steps: - With wl_display_prepare_read() all threads announce their intention to read. - wl_display_read_events() is thread save. On threads reads, the other wait for it to finish. - With wl_display_dispatch_queue_pending() each thread dispatches its own events. wl_display_dispatch_queue_pending() was defined since wayland 1.0.2 Original-patch-by: Michael Olbrich <m.olbrich@pengutronix.de> * stripped out the unlock() unlock_stop() logic * stripped out the poll handling Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Created attachment 303383 [details] [review] wayland: decouple wl_buffer from frame This patch takes out the wayland's buffer from the the frame structure. The buffer is queued to wayland and destroyed in the "release" callback. The frame is freed in the surface's "done" callback. In this way a buffer may be leaked but not the whole frame structure. - surface 'done' callback is used to throttle the rendering operation and to unallocate the frame, but not the buffer. - buffer 'release' callback is used to destroy wl_buffer. Original-patch-by: Zhao Halley <halley.zhao@intel.com> * code rebase * kept the the event_queue for buffer's proxy Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Created attachment 303384 [details] [review] wayland: use a counter as sync flag Wayland window has a pointer to the last pushed frame and use it to set the flag for stopping the queue dispatch loop. This may lead to memory leaks, since we are not keeping track of all the queued frames structures. This patch removes the last pushed frame pointer and change the binary flag for an atomic counter, keeping track of number of queued frames and use it for the queue dispatch loop.
Created attachment 303385 [details] [review] wayland: rename frame for last_frame Since frame in the private data means the last frame sent, it would semantically better use last_frame. Also, this patch makes use of g_atomic_pointer_{compare_and_exchange, set}() functions.
Created attachment 303386 [details] [review] wayland: wl_display_dispatch_queue() can block forever. wl_display_dispatch_queue() might prevent the pipeline from shutting down. This can happen e.g. if the wayland compositor exits while the pipeline is running. This patch replaces it with these steps: - With wl_display_prepare_read() all threads announce their intention to read. - wl_display_read_events() is thread save. On threads reads, the other wait for it to finish. - With wl_display_dispatch_queue_pending() each thread dispatches its own events. wl_display_dispatch_queue_pending() was defined since wayland 1.0.2 Original-patch-by: Michael Olbrich <m.olbrich@pengutronix.de> * stripped out the unlock() unlock_stop() logic * stripped out the poll handling Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
Created attachment 303387 [details] [review] vaapisink: implement unlock/unlock_stop for wayland Otherwise wl_display_dispatch_queue() might prevent the pipeline from shutting down. This can happen e.g. if the wayland compositor exits while the pipeline is running. Changes: * renamed unlock()/unlock_stop() to unblock()/unblock_cancel() in gstvaapiwindow * splitted the patch removing wl_display_dispatch_queue() Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> https://bugzilla.gnome.org/show_bug.cgi?id=747492
Created attachment 303388 [details] [review] wayland: sync() when destroy() Before pushing a the new frame, the render() method calls sync() to flush the pending frames. Nonetheless, the last pushed frame never gets rendered, leading to a memory leak too. This patch calls sync() in the destroy() to flush the pending frames before destroying the window. Also a is_cancelled flag is added. This flag tells to not flush the event queue again since the method failed previously or were cancelled by the user.
Attachment 303383 [details] pushed as 62c3888 - wayland: decouple wl_buffer from frame Attachment 303384 [details] pushed as c80951a - wayland: use a counter as sync flag Attachment 303385 [details] pushed as 882387d - wayland: rename frame for last_frame
Attachment 303386 [details] pushed as 522ec79 - wayland: wl_display_dispatch_queue() can block forever. Attachment 303387 [details] pushed as 11b9260 - vaapisink: implement unlock/unlock_stop for wayland
Attachment 303388 [details] pushed as 70eff01 - wayland: sync() when destroy()