Skip to content

Commit 3060999

Browse files
committed
web: Detect and log whether WebAssembly extensions are actually used
1 parent 442f0f6 commit 3060999

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

web/packages/core/src/ruffle-player.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,11 @@ export class RufflePlayer extends HTMLElement {
427427
this,
428428
config
429429
);
430-
console.log("New Ruffle instance created.");
430+
console.log(
431+
"New Ruffle instance created (WebAssembly extensions: " +
432+
(ruffleConstructor.is_wasm_simd_used() ? "ON" : "OFF") +
433+
")"
434+
);
431435

432436
// In Firefox, AudioContext.state is always "suspended" when the object has just been created.
433437
// It may change by itself to "running" some milliseconds later. So we need to wait a little

web/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,15 @@ impl Ruffle {
454454
})
455455
.unwrap_or_default()
456456
}
457+
458+
/// Returns whether the `simd128` target feature was enabled at build time.
459+
/// This is intended to discriminate between the two WebAssembly module
460+
/// versions, one of which uses WebAssembly extensions, and the other one
461+
/// being "vanilla". `simd128` is used as proxy for most extensions, since
462+
/// no other WebAssembly target feature is exposed to `cfg!`.
463+
pub fn is_wasm_simd_used() -> bool {
464+
cfg!(target_feature = "simd128")
465+
}
457466
}
458467

459468
impl Ruffle {

0 commit comments

Comments
 (0)