servo / pathfinder

A fast, practical GPU rasterizer for fonts and vector graphics
Apache License 2.0
3.6k stars 201 forks source link

assertion failed: iteration < MAX_ITERATIONS', renderer/src/tiler.rs:221:9 #416

Closed jimblandy closed 4 years ago

jimblandy commented 4 years ago

In a debug build, the attached program panics in the tiler, failing this assertion:

        // Quick check to catch missing the end tile.
        debug_assert!(iteration < MAX_ITERATIONS);

Backtrace of the crashing thread:

   0:     0x5556dfa1d985 - backtrace::backtrace::libunwind::trace::h34afbfad7fd770fc
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1:     0x5556dfa1d985 - backtrace::backtrace::trace_unsynchronized::h460d522b1619a600
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2:     0x5556dfa1d985 - std::sys_common::backtrace::_print_fmt::ha45fac10086813b4
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x5556dfa1d985 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hde84f63fcfd0e6de
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x5556dfa43f3c - core::fmt::write::h540ac4a6a1232abc
                               at src/libcore/fmt/mod.rs:1076
   5:     0x5556dfa1a8c2 - std::io::Write::write_fmt::hc344eafd6e850b4d
                               at src/libstd/io/mod.rs:1537
   6:     0x5556dfa1fe70 - std::sys_common::backtrace::_print::h4db88ff15cb5d61d
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x5556dfa1fe70 - std::sys_common::backtrace::print::h5fc39e1b1f610bd3
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x5556dfa1fe70 - std::panicking::default_hook::{{closure}}::h59e55edacb1d974a
                               at src/libstd/panicking.rs:198
   9:     0x5556dfa1fbbc - std::panicking::default_hook::heee4c8016dfbf328
                               at src/libstd/panicking.rs:217
  10:     0x5556dfa204b3 - std::panicking::rust_panic_with_hook::h8405b6301c79fb5a
                               at src/libstd/panicking.rs:526
  11:     0x5556df9b2ad9 - std::panicking::begin_panic::h6cb558c623d0248d
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/libstd/panicking.rs:456
  12:     0x5556df89461d - pathfinder_renderer::tiler::process_line_segment::h91adbc943b5d2ca0
                               at renderer/src/tiler.rs:221
  13:     0x5556df89409c - pathfinder_renderer::tiler::process_segment::h876dcfe83cc51351
                               at renderer/src/tiler.rs:175
  14:     0x5556df8937ff - pathfinder_renderer::tiler::Tiler::generate_fills::h1270b1f06c0fc8ab
                               at renderer/src/tiler.rs:86
  15:     0x5556df8933a6 - pathfinder_renderer::tiler::Tiler::generate_tiles::hcbd2c32fc4ea81c7
                               at renderer/src/tiler.rs:69
  16:     0x5556df88188a - pathfinder_renderer::builder::SceneBuilder::build_draw_path_on_cpu::h2d3b2c8391234159
                               at renderer/src/builder.rs:310
  17:     0x5556df0870f4 - pathfinder_renderer::builder::SceneBuilder::build_paths_on_cpu::{{closure}}::h87622b32b01483f8
                               at /home/jimb/rust/pathfinder/renderer/src/builder.rs:241
  18:     0x5556df088042 - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut::hb95fbbaf886b4915
                               at /home/jimb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:253
  19:     0x5556df08809f - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once::hc4d650bb9a04d351
                               at /home/jimb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:286
  20:     0x5556df0c1561 - core::option::Option<T>::map::hf7059d9e827184ab
                               at /home/jimb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/option.rs:453
  21:     0x5556df0a20a3 - <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::next::h5a13b193088edf7d
                               at /home/jimb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/adapters/mod.rs:852
  22:     0x5556defcab2c - rayon::iter::plumbing::Folder::consume_iter::h1c3ea08f1367f2ef
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/plumbing/mod.rs:178
  23:     0x5556df052882 - <rayon::iter::map::MapFolder<C,F> as rayon::iter::plumbing::Folder<T>>::consume_iter::h4f1f27ef1638ae36
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/map.rs:248
  24:     0x5556df06306d - rayon::iter::plumbing::Producer::fold_with::h14e43c0cf5168000
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/plumbing/mod.rs:110
  25:     0x5556df07a51c - rayon::iter::plumbing::bridge_producer_consumer::helper::he5fd40bc36be7422
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/plumbing/mod.rs:438
  26:     0x5556df07b74d - rayon::iter::plumbing::bridge_producer_consumer::helper::{{closure}}::he194b5ed6a7b2786
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/plumbing/mod.rs:427
  27:     0x5556df09a2dc - rayon_core::join::join_context::call_b::{{closure}}::haa58680e3a7908bf
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.7.1/src/join/mod.rs:130
  28:     0x5556df003d67 - <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute::call::{{closure}}::h94d85635c71a1da1
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.7.1/src/job.rs:113
  29:     0x5556df0839c2 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hb67d6edc81e3edde
                               at /home/jimb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:318
  30:     0x5556defc8c73 - std::panicking::try::do_call::h0972805eee379c33
                               at /home/jimb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:348
  31:     0x5556defc9f4d - __rust_try
  32:     0x5556defc8650 - std::panicking::try::habf74b41efeb7dbd
                               at /home/jimb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panicking.rs:325
  33:     0x5556df083c98 - std::panic::catch_unwind::h644c77ee11837814
                               at /home/jimb/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/panic.rs:394
  34:     0x5556df0cce92 - rayon_core::unwind::halt_unwinding::h60ae52c884cf6677
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.7.1/src/unwind.rs:17
  35:     0x5556df002c48 - <rayon_core::job::StackJob<L,F,R> as rayon_core::job::Job>::execute::h3e7569ba08940e5a
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.7.1/src/job.rs:119
  36:     0x5556df8f64de - rayon_core::job::JobRef::execute::hedf1fbc85b0473dd
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.7.1/src/job.rs:59
  37:     0x5556df8e7b15 - rayon_core::registry::WorkerThread::execute::hcd9f681384e7f870
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.7.1/src/registry.rs:685
  38:     0x5556df8e7802 - rayon_core::registry::WorkerThread::wait_until_cold::hfd3e14155e66d7c5
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.7.1/src/registry.rs:669
  39:     0x5556df8e71e6 - rayon_core::registry::WorkerThread::wait_until::hbf64c611049d299a
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.7.1/src/registry.rs:643
  40:     0x5556df8e8314 - rayon_core::registry::main_loop::h73be581361dce700
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.7.1/src/registry.rs:763
  41:     0x5556df8e5210 - rayon_core::registry::ThreadBuilder::run::h810d804e4c0e3384
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.7.1/src/registry.rs:56
  42:     0x5556df8e5711 - <rayon_core::registry::DefaultSpawn as rayon_core::registry::ThreadSpawn>::spawn::{{closure}}::hea2271a2ff9e2e9e
                               at /home/jimb/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-core-1.7.1/src/registry.rs:101
  43:     0x5556df8fcf40 - std::sys_common::backtrace::__rust_begin_short_backtrace::h8d7fb4f23302cc00
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/libstd/sys_common/backtrace.rs:130
  44:     0x5556df8faa61 - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::hc19709a3d82593f6
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/libstd/thread/mod.rs:475
  45:     0x5556df8f9ce3 - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h75f269f72c1e978b
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/libstd/panic.rs:318
  46:     0x5556df8ec1f4 - std::panicking::try::do_call::hd19ed5f2c4616474
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/libstd/panicking.rs:348
  47:     0x5556df8ed82d - __rust_try
  48:     0x5556df8ebeb4 - std::panicking::try::h66762a60913c07a2
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/libstd/panicking.rs:325
  49:     0x5556df8f9d23 - std::panic::catch_unwind::ha893fdf8d2f6f211
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/libstd/panic.rs:394
  50:     0x5556df8fa851 - std::thread::Builder::spawn_unchecked::{{closure}}::h246aca93a05213a6
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/libstd/thread/mod.rs:474
  51:     0x5556df8f436f - core::ops::function::FnOnce::call_once{{vtable.shim}}::he8c93857f18c44a0
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/libcore/ops/function.rs:233
  52:     0x5556dfa230ca - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h13d34828db364579
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/liballoc/boxed.rs:1081
  53:     0x5556dfa230ca - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hd51b619e0f884abf
                               at /rustc/346aec9b02f3c74f3fce97fd6bda24709d220e49/src/liballoc/boxed.rs:1081
  54:     0x5556dfa230ca - std::sys::unix::thread::Thread::new::thread_start::h02c6e34c2c73f344
                               at src/libstd/sys/unix/thread.rs:87
  55:     0x7f217ce184c0 - start_thread
  56:     0x7f217c9d8133 - clone
  57:                0x0 - <unknown>

lissajous.zip

jimblandy commented 4 years ago

For the program to run at all on Fedora 30, I need to set an environment variable:

$ MESA_GL_VERSION_OVERRIDE=3.3 cargo run
jimblandy commented 4 years ago

Forgot to mention: to compile the program, unpack the ZIP file in pathfinder/examples - it should create the lissajous subdir - and add examples/lissajous to the workspace. Then the relative paths in lissajous/Cargo.toml will be correct, and it will be able to find the pathfinder resources.

jimblandy commented 4 years ago

It seems to have something to do with drawing the performance graphs with the scale established by render_demo. Adding a save/restore pair to render_demo or not calling the performance graphs' render methods prevents the crash.

alec-deason commented 4 years ago

I'm seeing some sort of regression from 41ad372. Before that commit my scenes render in much less than a second but with that commit calls to build_and_render simply don't return, at least in the amount of time I've been willing to wait. I'm rendering moderately complex scenes to an off screen surface. I don't have a minimal example to show the problem yet but I'll try to put something together.

alec-deason commented 4 years ago

The problem appears to be with paths that overlap the viewport boundary. In my environment this example hangs on build_and_render: https://gist.github.com/alec-deason/a093aecaebbed430f59df624547efa2f

But if you use the configuration in the comments on line 105 it works as expected. The difference is that the broken version renders a bunch of arcs partially out of view and the working version moves them entirely into view. I see the same behavior in my real code, if I'm very careful to only create paths that are fully in view everything is fine but as soon as I have a non-trivial number of paths completely or partially out of view it fails.

If you think this should be a separate issue, let me know and I'll open one.

jdm commented 4 years ago

Filing a new issue instead of using a closed one will be easier to track.