Skip to content

ArcRefCell panic when running Stylo concurrently in multiple threads #361

Description

@nicoburns

Blitz bug report: DioxusLabs/blitz#430
Reproduction repo: https://github.com/ealmloff/blitz-stylo-race

Uses style_config::set_pref!("layout.threads", -1);. Setting that to 0 or 1 seems to prevent the panics (not tested thoroughly).

use blitz_dom::{Document as _, DocumentConfig};
use blitz_html::HtmlDocument;
use std::thread;

fn main() {
    let html = "<div></div>".repeat(64);
    let handles: Vec<_> = (0..16)
        .map(|_| {
            let html = html.clone();
            thread::spawn(move || {
                for _ in 0..1000 {
                    HtmlDocument::from_html(&html, DocumentConfig::default())
                        .inner_mut()
                        .resolve(0.0);
                }
            })
        })
        .collect();

    for h in handles {
        h.join().expect("a worker thread panicked");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions