feat(perf): 🎸 enable thorvg multi threaded rendering
Fixes #141
⚠️ No Changeset found
Latest commit: c3dc9dcb13f49f082b45f052034b521866800e78
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
@hermet after enabling thorvg multi threaded rendering, i'm not getting the frame buffer updated anymore and getting a blank canvas.
in thorvg.rs module, i'm passing the threads count to tvg_engine_init, am i missing something ?
impl Canvas {
pub fn new(engine_method: TvgEngine, threads: u32) -> Self {
let engine = match engine_method {
TvgEngine::TvgEngineSw => Tvg_Engine_TVG_ENGINE_SW,
TvgEngine::TvgEngineGl => Tvg_Engine_TVG_ENGINE_GL,
};
let init_result = unsafe { tvg_engine_init(engine, threads) };
if init_result != Tvg_Result_TVG_RESULT_SUCCESS {
panic!("Failed to initialize ThorVG engine");
}
Canvas {
raw_canvas: unsafe { tvg_swcanvas_create() },
engine_method: engine,
}
}
....
@theashraf What value did you use for the thread number, and which platform did you test it on? Please note that SharedArrayBuffer, required in web, would have a security issue now, the thorvg intrinsic thread feature might not be proper for the web (let me double check it) but other platforms such as android and iOS should be ok.
+ @tinyjin
@hermet, I've tested it on Rust on my macOS, not on the web. I set the number of threads to 1, as shown in this rust example.
I'm not trying to test it on the web for now. I want to ship this for platforms with native threading capability, like iOS and Android.
@theashraf Hello, Ashraf. I've only tested the native threading in web. It required enabling a few options
-pthread-sUSE_PTHREADS=1-sPTHREAD_POOL_SIZE
Of course, they're part of Emscripten flags, I'm not sure it'd help even in Android, iOS and Rust.