Auto merge of #23000 - jdm:invisible-webgl, r=nox

Make webgl behave better with session history

This prevents the compositor from animating pages that are not actually visible, so pages using webgl do not needlessly impact the performance of the rest of the browser. Additionally, this fixes a problem that was alluded to in [this code](b5228c098b/src/draw_buffer.rs (L282-L285)), causing Servo to delete arbitrary resources when a GC occurred in content that used three.js.

- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #22987 and fix #22977 and fix #20934 and fix #20953 and fix #20930 and fix #20950 and fix #20924
- [x] There are tests for these changes

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23000)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-03-08 10:46:52 -05:00 committed by GitHub
commit 34a5a824b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 145 additions and 0 deletions

View file

@ -380,6 +380,10 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> {
self.webrender_api.update_resources(txn.resource_updates)
}
// We need to make the context current so its resources can be disposed of.
let _ =
Self::make_current_if_needed(context_id, &self.contexts, &mut self.bound_context_id);
// Release GL context.
self.contexts.remove(&context_id);