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

Panic when setting canvas width or height #17277

Closed
asajeffrey opened this issue Jun 12, 2017 · 1 comment
Closed

Panic when setting canvas width or height #17277

asajeffrey opened this issue Jun 12, 2017 · 1 comment

Comments

@asajeffrey
Copy link
Member

@asajeffrey asajeffrey commented Jun 12, 2017

Setting the canvas dimensions causes a panic. For example:

<!doctype html>
<html>
    <body>
        <canvas width="50px" height="50px"></canvas>
        <script>
            var canvas = document.getElementsByTagName('canvas')[0];
            var ctx = canvas.getContext('2d');
            ctx.fillStyle = "red";
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            setTimeout(function() {
                canvas.width = 100;
                canvas.height = 100;
                ctx.fillStyle = "green";
                ctx.fillRect(0, 0, canvas.width, canvas.height);
            }, 0);
        </script>
    </body>
</html>

produces:

assertion failed: `(left == right)` (left: `50`, right: `100`) (thread RenderBackend, at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/webrender-c3596abe1cf4f320/caec344/webrender/src/resource_cache.rs:298)
stack backtrace:
   0:     0x5595230c1734 - backtrace::backtrace::libunwind::trace
                        at /home/ajeffrey/github/asajeffrey/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.2/src/backtrace/libunwind.rs:53
                         - backtrace::backtrace::trace<closure>
                        at /home/ajeffrey/github/asajeffrey/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.2/src/backtrace/mod.rs:42
   1:     0x5595230b9bdf - backtrace::capture::{{impl}}::new
                        at /home/ajeffrey/github/asajeffrey/servo/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.2/src/capture.rs:64
   2:     0x55951e816446 - servo::main::{{closure}}
                        at /home/ajeffrey/github/asajeffrey/servo/ports/servo/main.rs:129
   3:     0x55952405110a - std::panicking::rust_panic_with_hook
                        at /checkout/src/libstd/panicking.rs:550
   4:     0x559524050fa4 - std::panicking::begin_panic<collections::string::String>
                        at /checkout/src/libstd/panicking.rs:511
   5:     0x559524050ed9 - std::panicking::begin_panic_fmt
                        at /checkout/src/libstd/panicking.rs:495
   6:     0x559521f9d65e - webrender::resource_cache::{{impl}}::update_image_template
                        at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/webrender-c3596abe1cf4f320/caec344/webrender/src/resource_cache.rs:298
   7:     0x559521e4452d - webrender::render_backend::{{impl}}::run
                        at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/webrender-c3596abe1cf4f320/caec344/webrender/src/render_backend.rs:158
   8:     0x559521d3dd23 - webrender::renderer::{{impl}}::new::{{closure}}
                        at /home/ajeffrey/github/asajeffrey/servo/.cargo/git/checkouts/webrender-c3596abe1cf4f320/caec344/webrender/src/renderer.rs:1136
   9:     0x559521c3aaea - std::sys_common::backtrace::__rust_begin_short_backtrace<closure,()>
                        at /checkout/src/libstd/sys_common/backtrace.rs:136
  10:     0x559521ee4e23 - std::thread::{{impl}}::spawn::{{closure}}::{{closure}}<closure,()>
                        at /checkout/src/libstd/thread/mod.rs:364
  11:     0x559521f6c0da - std::panic::{{impl}}::call_once<(),closure>
                        at /checkout/src/libstd/panic.rs:296
  12:     0x559521ee6409 - std::panicking::try::do_call<std::panic::AssertUnwindSafe<closure>,()>
                        at /checkout/src/libstd/panicking.rs:454
  13:     0x55952405826a - panic_unwind::__rust_maybe_catch_panic
                        at /checkout/src/libpanic_unwind/lib.rs:98
  14:     0x559521ee57ac - std::panicking::try<(),std::panic::AssertUnwindSafe<closure>>
                        at /checkout/src/libstd/panicking.rs:433
  15:     0x559521ee48c5 - std::panic::catch_unwind<std::panic::AssertUnwindSafe<closure>,()>
                        at /checkout/src/libstd/panic.rs:361
  16:     0x559521c6983b - std::thread::{{impl}}::spawn::{{closure}}<closure,()>
                        at /checkout/src/libstd/thread/mod.rs:363
  17:     0x559521c9f0f3 - alloc::boxed::{{impl}}::call_box<(),closure>
                        at /checkout/src/liballoc/boxed.rs:648
  18:     0x55952404fd65 - alloc::boxed::{{impl}}::call_once<(),()>
                        at /checkout/src/liballoc/boxed.rs:658
                         - std::sys_common::thread::start_thread
                        at /checkout/src/libstd/sys_common/thread.rs:21
                         - std::sys::imp::thread::{{impl}}::new::thread_start
                        at /checkout/src/libstd/sys/unix/thread.rs:84
  19:     0x7f53cb8e26a9 - start_thread
  20:     0x7f53cb40113c - __clone
  21:                0x0 - <unknown>
ERROR:servo: assertion failed: `(left == right)` (left: `50`, right: `100`)
@asajeffrey
Copy link
Member Author

@asajeffrey asajeffrey commented Jun 12, 2017

IRC conversation with @bzbarsky: http://logs.glob.uno/?c=mozilla%23servo&s=12+Jun+2017&e=12+Jun+2017#c695098

TL;DR we should clear the WR image id when we resize a canvas.

bors-servo added a commit that referenced this issue Jun 13, 2017
…en-resizing, r=emilio

Clear webrender image id when resizing a canvas.

<!-- Please describe your changes on the following line: -->

Webrender isn't very happy if images change size, so clear the webrender image key when resizing a canvas.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #17277
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/17278)
<!-- 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.