Re: [css-font-loading] Timing clarification of ready attribute/promise

On Mon, Aug 3, 2015 at 2:00 AM, Dominik Röttsches <drott@google.com> wrote:
> Hi,
>
> I am trying to get a clearer picture on the exact timing of the ready
> promise getting resolved:
>
> >From https://drafts.csswg.org/css-font-loading/#font-face-set-ready :
> "The ready attribute contains a Promise which is resolved when the
> document is done loading fonts"
>
> And further down, in the non-normative note:
> "The ready promise is only fulfilled after layout operations complete
> and no additional font loads are necessary."
>
> What I noticed in Chrome, while working on a larger font-loading
> related test case:
> Depending on machine performance, there is a small delay <100ms
> between the promise getting resolved, and the fonts actually being
> used for rendering. And I am curious whether this - in the spirit of
> the spec - a bug or acceptable behaviour.
>
> Does the "after layout operations complete" note imply that the fonts
> that just completed loading are used for rendering and the screen is
> updated with those?
>
> Could the timing of this promise-resolution be made more exact and and
> moved from the note to a normative statement?

The spec defines that the ready promise isn't fulfilled until the
browser is no longer "pending on the environment"
<https://drafts.csswg.org/css-font-loading/#pending-on-the-environment>.
The (normative) third bullet point for that is "the document has
pending layout operations which might cause the user agent to request
a font".

This is definitely *supposed* to imply that any font-dependent layout
has finished, so that when the ready promise is fulfilled, JS can go
and measure things in the DOM and be sure that there won't be anything
jumping around due to font loads (until the next time something
triggers a load, of course).

If this isn't happening, it's definitely a bug, either in the impl or
the spec (or both).  Do you think the current spec line isn't
sufficiently clear?  If so, I can try to tighten the language.

~TJ

Received on Wednesday, 5 August 2015 23:34:00 UTC