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

Going forwards in history to a webgl page panics #22987

Closed
jdm opened this issue Mar 6, 2019 · 5 comments
Closed

Going forwards in history to a webgl page panics #22987

jdm opened this issue Mar 6, 2019 · 5 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Mar 6, 2019

STR:

  1. load https://threejs.org/examples
  2. choose the cloth example
  3. watch it load
  4. go back in history
  5. go forward in history

Expected:
Cloth example continues running.

Actual:

[2019-03-06T21:00:19Z ERROR canvas::webgl_thread] Last GL operation failed: BindBuffer(34962, Some(WebGLBufferId(2)))
[2019-03-06T21:00:19Z WARN  servo] Panic hook called.
assertion failed: `(left == right)`
  left: `1286`,
 right: `0`: Unexpected WebGL error: 0x506 (1286) (thread WebGLThread, at components/canvas/webgl_thread.rs:1437)
stack backtrace:
   0:        0x10fe07c34 - __ZN9backtrace9backtrace5trace17h9f3458ac04360c1aE
                        at /Users/jdm/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/backtrace/mod.rs:42
   1:        0x10fe025dc - __ZN9backtrace7capture9Backtrace14new_unresolved17h21921a7295046aa9E
                        at /Users/jdm/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/capture.rs:88
   2:        0x10fe0253e - __ZN9backtrace7capture9Backtrace3new17h18226acc03ed089aE
                        at /Users/jdm/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.9/src/capture.rs:63
   3:        0x109a61065 - __ZN5servo4main28_$u7b$$u7b$closure$u7d$$u7d$17h6511ddc8f2676f98E
                        at ports/servo/non_android_main.rs:110
   4:        0x11121cf90 - __ZN3std9panicking20rust_panic_with_hook17hc96a2ab9717cf47bE
                        at src/libstd/panicking.rs:482
   5:        0x11121c9dc - __ZN3std9panicking18continue_panic_fmt17h829e4b1e6e9a8f39E
                        at src/libstd/panicking.rs:385
   6:        0x11121c930 - __ZN3std9panicking15begin_panic_fmt17h3a4ef0ccd095e4a0E
                        at src/libstd/panicking.rs:340
   7:        0x10e5ccda6 - __ZN6canvas12webgl_thread9WebGLImpl5apply17h917b1f0ddac611b4E
                        at components/canvas/webgl_thread.rs:1437
   8:        0x10e60138f - __ZN6canvas10gl_context16GLContextWrapper13apply_command17hf77262daa18fd2eeE
                        at components/canvas/gl_context.rs:164
   9:        0x10e5bbaa1 - __ZN52_$LT$canvas..webgl_thread..WebGLThread$LT$VR$GT$$GT$20handle_webgl_command17hd3d963302b8b7085E
                        at components/canvas/webgl_thread.rs:207
  10:        0x10e5bada9 - __ZN52_$LT$canvas..webgl_thread..WebGLThread$LT$VR$GT$$GT$10handle_msg17h7f91a54c252d5633E
                        at components/canvas/webgl_thread.rs:169
  11:        0x10e5ba76e - __ZN52_$LT$canvas..webgl_thread..WebGLThread$LT$VR$GT$$GT$5start28_$u7b$$u7b$closure$u7d$$u7d$17h84f50790bf709a1eE
                        at components/canvas/webgl_thread.rs:106
  12:        0x10e5e66e3 - __ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h56911288a4a75b0fE
                        at /rustc/0ea22717a1e01fa535534b85a5347a7e49fc79de/src/libstd/sys_common/backtrace.rs:136
  13:        0x10e736d50 - __ZN3std6thread7Builder15spawn_unchecked28_$u7b$$u7b$closure$u7d$$u7d$28_$u7b$$u7b$closure$u7d$$u7d$17h1648794bce76646aE
                        at /rustc/0ea22717a1e01fa535534b85a5347a7e49fc79de/src/libstd/thread/mod.rs:469
  14:        0x10e5d4a83 - __ZN101_$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$9call_once17h29285d785e46d502E
                        at /rustc/0ea22717a1e01fa535534b85a5347a7e49fc79de/src/libstd/panic.rs:309
  15:        0x10e5e6c3f - __ZN3std9panicking3try7do_call17h299d8907f865ed34E
                        at /rustc/0ea22717a1e01fa535534b85a5347a7e49fc79de/src/libstd/panicking.rs:297
  16:        0x11122621e - ___rust_maybe_catch_panic
                        at src/libpanic_unwind/lib.rs:87
  17:        0x10e5e6b24 - __ZN3std9panicking3try17hb778a41606c7c91dE
                        at /rustc/0ea22717a1e01fa535534b85a5347a7e49fc79de/src/libstd/panicking.rs:276
  18:        0x10e5e6983 - __ZN3std5panic12catch_unwind17hb221ebc2569bff03E
                        at /rustc/0ea22717a1e01fa535534b85a5347a7e49fc79de/src/libstd/panic.rs:388
  19:        0x10e736923 - __ZN3std6thread7Builder15spawn_unchecked28_$u7b$$u7b$closure$u7d$$u7d$17h0dc9110979604618E
                        at /rustc/0ea22717a1e01fa535534b85a5347a7e49fc79de/src/libstd/thread/mod.rs:468
  20:        0x10e745447 - __ZN50_$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$8call_box17h5ad430700f108549E
                        at /rustc/0ea22717a1e01fa535534b85a5347a7e49fc79de/src/liballoc/boxed.rs:749
  21:        0x11122564b - __ZN3std3sys4unix6thread6Thread3new12thread_start17hb65474f74178fcb3E
                        at src/libstd/sys_common/thread.rs:14
  22:     0x7fffe4b1793a - __pthread_body
  23:     0x7fffe4b17886 - __pthread_start
@jdm
Copy link
Member Author

@jdm jdm commented Mar 6, 2019

In a release build I hit this assertion immediately when going back in history on macOS:

[2019-03-06T21:04:33Z ERROR canvas::webgl_thread] Last GL operation failed: Clear(17664)
assertion failed: `(left == right)`
  left: `1286`,
 right: `0`: Unexpected WebGL error: 0x506 (1286) (thread WebGLThread, at components/canvas/webgl_thread.rs:1437)
@jdm
Copy link
Member Author

@jdm jdm commented Mar 6, 2019

The patch I wrote for #22977 makes the assertion I just mentioned go away, which is the same as #20924.

@jdm
Copy link
Member Author

@jdm jdm commented Mar 6, 2019

The original assertion is triggered by a GC of an extraneous webgl context that's created at https://github.com/mrdoob/three.js/blob/63eca7a87695703e23ccce326f95ffba259e8e19/examples/js/WebGL.js#L13 and never used again.

@jdm
Copy link
Member Author

@jdm jdm commented Mar 6, 2019

Specifically, removing the GL context from self.contexts triggers the assertion. I suspect the Drop implementation for NativeGLContext is at fault on macOS.

@jdm
Copy link
Member Author

@jdm jdm commented Mar 7, 2019

Dropping the GLContext drops the DrawBuffer, but if the context is not actually current we end up deleting framebuffers and renderbuffers for an inactive context. That's no good!

@jdm jdm mentioned this issue Mar 8, 2019
4 of 4 tasks complete
bors-servo added a commit that referenced this issue Mar 8, 2019
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](https://github.com/servo/rust-offscreen-rendering-context/blob/b5228c098b889a9806a5f93582903e192b3939ef/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 -->
bors-servo added a commit that referenced this issue Mar 8, 2019
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](https://github.com/servo/rust-offscreen-rendering-context/blob/b5228c098b889a9806a5f93582903e192b3939ef/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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant
You can’t perform that action at this time.