[PATCH weston] libweston: don't accumulate damage from transparent views

Ucan, Emre (ADITG/ESB) eucan at de.adit-jv.com
Tue May 8 07:27:24 UTC 2018

Hi Pekka,

> -----Original Message-----
> From: Pekka Paalanen [mailto:ppaalanen at gmail.com]
> Sent: Freitag, 4. Mai 2018 15:27
> To: Ucan, Emre (ADITG/ESB) <eucan at de.adit-jv.com>
> Cc: wayland-devel at lists.freedesktop.org
> Subject: Re: [PATCH weston] libweston: don't accumulate damage from
> transparent views
> On Fri, 4 May 2018 12:09:55 +0000
> "Ucan, Emre (ADITG/ESB)" <eucan at de.adit-jv.com> wrote:
> > Hi Pekka,
> >
> > Sorry for late response.
> Hi Emre,
> no worries!
> > > -----Original Message-----
> > > From: Pekka Paalanen [mailto:ppaalanen at gmail.com]
> > > Sent: Donnerstag, 19. April 2018 12:36
> > > To: Ucan, Emre (ADITG/ESB)
> > > Cc: wayland-devel at lists.freedesktop.org
> > > Subject: Re: [PATCH weston] libweston: don't accumulate damage from
> > > transparent views
> > >
> > You are right that this issue can be work around for an EGL
> > application when we set swapInterval to 0, and send a new buffer
> > every time internal state of the application requires to change its
> > contents. But this does not fix the greediness problem. Because
> > application state can change more often than display refresh rate.
> The key with EGL is to never allow eglSwapBuffers() block. The app can
> still ask for frame callbacks itself and throttle to those while
> remaining otherwise responsive.
> eglSwapBuffers() has been designed to be blocking in nature, i.e. it
> has been designed to waste time. Any application that has more than one
> window or needs to react to more than just Wayland input events or
> needs to run a simulation (games!) would better set swapInterval to
> zero. If they don't, and they also don't manually throttle to frame
> callbacks, they are bound to waste time in eglSwapBuffers(), and this
> is not only a Wayland issue. Wayland just allows us to make this bad
> client design painfully obvious.
> > > Or is the camera framerate an exact integer fraction of the display
> > > refresh rate?
> > Ideally yes. Let's think that camera is sending buffer with 60 Hz and
> > display has also the same refresh rate. But camera and display could
> > be still out of sync, so that camera sends its buffer 8ms after
> > Vsync. Therefore, it will miss the repaint window of weston.
> >
> > It is also possible that camera buffers sometimes hit, sometimes miss
> > the repaint window. This would cause visible video stutter. Because
> > delay of displaying a buffer would swing between 0,5 Vsync to 1,5
> > Vsync ( Repaint window is 0.5 Vsync). Therefore, it is not ok to send
> > buffer every time when it is ready. We should send it directly after
> > repaint, so that (hopefully) we won't miss the repaint window.
> I don't think it changes much with respect to timings though. If the
> client was posting frames as soon as it got it from the camera, the
> compositor would be picking which ones make it to the screen. If the
> client is throttled to frame callbacks, then yes, any frame the client
> chooses will hit the screen, but now it is the client making the same
> choice as the compositor in the former case. Except, the client needs
> to make that decision earlier than the compositor.
> Can the client here be smarter than the compositor to make a difference?
> Given that we don't know about the deadline yet, discussed further
> below.
> > > I know there is a problem that when the surface becomes visible
> > > again, it would take a frame cycle to have the client send an
> > > updated buffer. This could be worked around on either side: the
> > > compositor could be sending frame callbacks at a slow rate even if
> > > the surface is not visible, or the client could be updating the
> > > surface content at a slow rate even if it doesn't get frame
> > > callbacks.
> >
> > But your proposal is also a hack.
> Right, but what else could you do, when you do not know in advance when
> the window will become visible and yet you want to minimize the number of
> frames drawn and discarded?
> The smartest option might be to postpone the actual show in the
> compositor until the client has updated, but that's a trade-off between
> latency from action to effect and a possible glitch (temporary outdated
> content).
> > Maybe better solution would be that
> > we introduce a repaint_window event to wl_output interface, so that
> > camera/video applications can synchronize themselves with this event
> > instead of surface frame events. Compositor can send a timestamp and
> > duration of repaint window to the clients.
> (That proposal does not solve the above issue.)
> Yeah, there has been talk about exposing the deadline timestamp for the
> next vblank (if the compositor processes a commit before this time, it
> will hit the refresh). It would help to minimize latency.
> However, I would not like an event that gets sent on every output
> refresh regardless of client updates. Instead, something like this
> might be workable:
> https://patchwork.freedesktop.org/patch/174555/
> We still want to minimize client and server wake-ups when possible.
> Mind, that you can also drive client updates by Presentation-time
> feedback events. They are still lacking the deadline information
> though, but they do carry the refresh period and phase.
> The feedback events are intended for video players to accurately
> predict the next time of presentation when they submit a frame as a
> response to each frame callback event. When you predict the time the
> next frame will become visible, you can choose and even interpolate a
> frame for that exact time. After all, the app could be able to compute
> intermediate frames, but the display hardware can only show discrete
> frames at certain times.

Nice! It is very similar to what I thought of. We can use it to continuously send new frames on the right time.
Is presentation protocol supported in any other compositor, or only in Weston?

Are you planning to push patch of Alexandros anytime soon?
> > > One possibility would be to exclude the view from
> > > weston_compositor::view_list which is used for both rendering and
> > > input picking. This would happen in
> > > weston_compositor_build_view_list(). It could also exclude
> > > completely occluded views, but we can leave that for another time.
> > >
> > > Excluding the view from the rendering list will avoid sending frame
> > > callbacks. It will also affect Presentation feedback in the expected
> > > way: the updates the compositor has decided to not show (e.g. by
> > > setting view alpha to zero) will not result in a "presented" event.
> > >
> > > Would you like to examine this path instead?
> >
> > You are right that it would be a better solution to not have
> > invisible views in the compositor view list. Daniel also implemented
> > to discard occluded views here: "
> > https://patchwork.freedesktop.org/patch/202693/". I can reuse it. But
> > my real intention for this patch was to mitigate the performance
> > penalty of hiding a surface via using opacity instead of visibility.
> > Technically, it is of course correct that invisible surfaces do not
> > get any frame events. But we need some other solution to synchronize
> > video applications with wayland compositors...
> Yes. I think the best way to mitigate the performance penalty is to
> completely exclude fully transparent surfaces from processing.
> Is the synchronization of fully invisible video surfaces actually a
> problem? There is the old content issue, but aside from that, it will
> be in sync again after the next frame callback on becoming visible
> again.

There are old content issue and missing deadlines issue. Both of them can be fixed by presentation protocol.

> Thanks,
> pq

Best Regards,

More information about the wayland-devel mailing list