On Fri, Sep 6, 2013 at 2:51 PM, Robert O'Callahan <rob...@ocallahan.org>wrote:

> On some non-main thread:
> 1. Wait for vsync event
> 2. Dispatch refresh driver ticks to all windows that don't already have a
> pending refresh driver tick unacknowledged by a layer tree update response
> 3. Wait for N ms, processing any layer-tree updates (where N = vsyncinterval 
> - generously estimated time to composite all windows)
> 4. Composite all updated windows
> 5. Goto 1
>
> This could happen on the compositor thread or some other thread depending
> on how "wait for vsync event" is implemented on each platform.
>

It's worth thinking about what happens if a window misses the Nms deadline,
either because it consistently takes more than Nms to paint or there's just
one slow frame due to GC or something like that.

For values of say N=10ms, vsync period 16ms, and a window paint time of
consistently 12ms, this approach will cut frame rate in half. That's not
what we want.

So we need to modify step 1:
1. Wait for vsync event, processing any layer-tree updates and compositing
those windows
2. Dispatch refresh driver ticks to all windows that got layer tree updates
since the last iteration of step 2
3. Wait for N ms, processing any layer-tree updates (where N =
vsyncinterval - generously estimated time to composite all windows)
4. Composite all windows that either received a layer-tree update or have
some kind of off-main-thread animation
5. Goto 1

This does mean if the window paint time is (e.g.) 12ms and it also has
off-main-thread animations, we composite it twice per frame. I don't see
any way around that.

Now with this, if the window paint time is say 18ms, we still cut the frame
rate in half, and that's still not good. So I think we need to modify this
some more: when we process a layer tree update, if we expected but did not
receive a layer tree update to that window during the previous vsync
interval, dispatch the next refresh driver tick to that window immediately
instead of waiting for the next vsync event. There are some tricky details
to work out though.

Rob
-- 
Jtehsauts  tshaei dS,o n" Wohfy  Mdaon  yhoaus  eanuttehrotraiitny  eovni
le atrhtohu gthot sf oirng iyvoeu rs ihnesa.r"t sS?o  Whhei csha iids  teoa
stiheer :p atroa lsyazye,d  'mYaonu,r  "sGients  uapr,e  tfaokreg iyvoeunr,
'm aotr  atnod  sgaoy ,h o'mGee.t"  uTph eann dt hwea lmka'n?  gBoutt  uIp
waanndt  wyeonut  thoo mken.o w  *
*
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to