Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't panic when an invalid font instance key is supplied #1664

Merged
merged 1 commit into from
Sep 8, 2017

Conversation

lsalzman
Copy link
Contributor

@lsalzman lsalzman commented Sep 5, 2017

This is a small modification to my previous FontInstanceKey to allow invalid font instance keys to work around the issue described in https://bugzilla.mozilla.org/show_bug.cgi?id=1396056

There are somewhat legitimate situations where this can occur, so we don't want to panic.


This change is Reviewable

@jrmuizel
Copy link
Collaborator

jrmuizel commented Sep 5, 2017

Can you describe those situations?

@glennw
Copy link
Member

glennw commented Sep 5, 2017

This seems reasonable to me - I think the API should probably not panic if an invalid key is supplied. Are you fine with merging this @jrmuizel ? We might like to consider having a "strict" mode in the future, where invalid API calls to panic?

@lsalzman
Copy link
Contributor Author

lsalzman commented Sep 5, 2017

Gankro at least found one case where we invalidate the whole font cache on the Gecko side while a display item using some of the fonts therein is in flight. Now, arguably, that could be looked at as a bug on its own, but I would rather just have us fail to render and warn in those situations rather than simply crash, since we will probably encounter similar bugs in the future in releases.

@jrmuizel
Copy link
Collaborator

jrmuizel commented Sep 5, 2017

I'd rather we crash so we catch these bugs earlier. If we need to turn off this panic than I'd rather it be because we're forced into it. This is basically a use after free and I'd like to better understand why we need that to be valid before giving into turning this into a warning.

@Gankra
Copy link
Contributor

Gankra commented Sep 5, 2017

I think this is a reasonable strategy. For the specific case, it means updating fonts can cause text to flicker for a frame; not a big deal. More broadly "not rendering" is a fairly reasonable solution to "no font", and if we ever have any serious bugs where we're losing fonts, the warnings should be fairly clear for those debugging it.

@glennw
Copy link
Member

glennw commented Sep 6, 2017

We recently changed the render call to return a Result which contains a list of errors that occurred while rendering the frame.

This is used to gracefully handle the situation where a driver fails to compile a normally valid shader (since they are compiled lazily on first use). See

pub fn render(&mut self, framebuffer_size: DeviceUintSize) -> Result<(), Vec<RendererError>> {
for details.

My suggestion is to merge this PR, and as a follow up I'll add the infrastructure to enable passing errors like this through the pipeline to be returned as part of the list of errors that occurred during rendering that frame.

If we do that, this will mean:

  • WR itself will emit a warning but not panic.
  • Client code can read the error list and choose what to do based on the error(s). For example, panic in a CI / debug build and log a warning in a production build.

@jrmuizel Does that sound reasonable?

@kvark
Copy link
Member

kvark commented Sep 7, 2017

@glennw plan sounds reasonable to me.
I'd also like to be sure that logging from warn! is configured to be visible (either on screen or via some Gecko-specific delivery mechanisms) by Firefox.

@glennw
Copy link
Member

glennw commented Sep 7, 2017

Added #1677 and #1678

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit f2ae2ce has been approved by glennw

bors-servo pushed a commit that referenced this pull request Sep 7, 2017
don't panic when an invalid font instance key is supplied

This is a small modification to my previous FontInstanceKey to allow invalid font instance keys to work around the issue described in https://bugzilla.mozilla.org/show_bug.cgi?id=1396056

There are somewhat legitimate situations where this can occur, so we don't want to panic.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1664)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

⌛ Testing commit f2ae2ce with merge 0d360c1...

@bors-servo
Copy link
Contributor

☀️ Test successful - status-travis
Approved by: glennw
Pushing 0d360c1 to master...

@bors-servo bors-servo merged commit f2ae2ce into servo:master Sep 8, 2017
glennw pushed a commit to glennw/saltfs that referenced this pull request Oct 20, 2017
bors-servo pushed a commit to servo/saltfs that referenced this pull request Oct 20, 2017
Add Gankro to WR reviewers list.

Some reviews in WR that Gankro has worked on:

servo/webrender#1830
servo/webrender#1799
servo/webrender#1834
servo/webrender#1664

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/740)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants