Questions tagged [rust-wasm]

121 questions
14
votes
1 answer

Why does wasm-opt fail in wasm-pack builds when generating a function returning a string?

I'm working through the Rust WASM tutorial for Conway's game of life. One of the simplest functions in the file is called Universe.render (it's the one for rendering a string representing game state). It's causing an error when I run wasm-pack…
vaer-k
  • 10,923
  • 11
  • 42
  • 59
10
votes
1 answer

Why is Rust WASM slower than JavaScript in calculating prime numbers

I wrote a very rudimentary piece of code to calculate if a number is prime in Rust (compiled to WASM) and in JavaScript to benchmark the arithmetic performance. I was fully expecting Rust/WASM to blow away JavaScript. In all other arithmetic…
Luke
  • 365
  • 2
  • 10
7
votes
0 answers

Why is bubble sort faster when implemented in JavaScript then when implemented in Wasm using Rust?

I wrote the bubble sort algorithm in JavaScript and Wasm using Rust and the JS code is faster than Rust code. How is this possible? JavaScript code import * as wasm from "wasm-comparision-sort-algorithms"; function main() { const arr =…
Eladiorocha
  • 146
  • 1
  • 6
6
votes
1 answer

WASM from Rust not returning the expected types

Hey @all I was playing with WebAssembly Studio and created an empty Rust project. In my Rust code, I'm returning the pointer and the length for my "Hello World" string. Compiling worked fine, but I was expecting the resulting WASM to have a function…
Alex Fischer
  • 193
  • 1
  • 2
  • 12
6
votes
1 answer

How to list the symbols in this WASM module?

I'm looking to do some in-browser video work using good-ol' FFmpeg and Rust. Simple examples, where the caller is interacting with the ffmpeg command-line abound. More complex examples are harder to find. In my case I wish to extract, process and…
Martin Cowie
  • 2,788
  • 7
  • 38
  • 74
5
votes
1 answer

Compiling Rust that calls C++ to WASM

I've found this How do I use a C library in a Rust library compiled to WebAssembly?, but this relies on wasm-merge, which has been discontinued. My problem is the following, I have some C++ code that I would like to call from Rust in order to have…
user8352734
4
votes
1 answer

How to embed a wasm artifact generated by one crate in a cargo workspace in a rust binary generated by another crate in the same workspace?

I have a cargo workspace organized like this: Cargo.toml |-foo | |-Cargo.toml | -src | |-main.rs |-foo-runtime | |-Cargo.toml | -src | |-lib.rs |-target main.rs has code somewhere that looks like use std::sync::LazyLock; use…
Aaron Roth
  • 41
  • 3
4
votes
1 answer

How to link a C library in Rust WASI

I want to use a C library in my rust-wasi program. but I am having trouble linking external libraries. My Current setup is this. main.rs #[link(name = "mylib")] extern "C" { pub fn add_one(i: i32) -> i32; } pub fn main() { let res = unsafe…
Kival M
  • 182
  • 1
  • 10
4
votes
0 answers

Why do these rustflags give me an out of memory exception?

I am working on a web assembly application in rust. The program relies on streaming a file and storing the data in memory. However I run into a rust_oom issue. This issue only arises when recompiling the std library with atomic, bulk-memory, and…
Kival M
  • 182
  • 1
  • 10
4
votes
0 answers

Unittests in Rust with WebAssembly

I'm writing a frontend in WASM by using the seed framework. I want to test one of my modules with unittests, but I can't make them to test WASM code. Here's my test suite: #[cfg(test)] mod tests { use super::*; #[test] fn…
Djent
  • 2,877
  • 10
  • 41
  • 66
4
votes
0 answers

How to exec js code on rust with wasm-bindgen correctly

I'm working with rust, WASM, and yew as frontend framework. I'm building a wrapper around materialize-css, to use it on yew as dependency of reusable components. To use some materialize-css components it's necesary initialize it. For example, to use…
al3x
  • 589
  • 1
  • 4
  • 16
4
votes
0 answers

The trait `IntoWasmAbi` is not implemented for `HashMap

Trying to compile following rust code to wasm to make it compatible running with existing js. Trying to return hashmaped value from function. lib.rs use wasm_bindgen::prelude::*; use std::collections::HashMap; #[wasm_bindgen] pub fn…
Anil Arya
  • 3,100
  • 7
  • 43
  • 69
4
votes
1 answer

how to create a grid and cells in Yew app

Yew app. I am trying to build a grid and inside grid I would like to arrange cells in Yew app. I would like to have My grid a 4*4 array Cells size would be 5px width and height I also need to set the Cell color property based on the method I solve…
Naveen
  • 109
  • 1
  • 6
4
votes
0 answers

Create React App import Wasm to Web Worker

I'm working with wasm-bindgen and a react app (created with create-react-app) and I'd like to import a wasm module into a web worker. I'm using this example, just to start out. To work with wasm on the "main-thread" I set up react-app-rewired,…
Mattia
  • 179
  • 15
3
votes
0 answers

Using web assembly on iOS

Hi I would like to ask if the webassembly technology is supported by wkwebview or if there are particular limitations. The second question is once an app has been developed where I have some sections inside that make use of web assembly modules, is…
1
2 3
8 9