Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum call stack error on the web #444

Open
temeddix opened this issue Sep 20, 2024 · 3 comments
Open

Maximum call stack error on the web #444

temeddix opened this issue Sep 20, 2024 · 3 comments

Comments

@temeddix
Copy link
Member

temeddix commented Sep 20, 2024

Report

As of September 2024, running a RInf app on the web in debug mode can print the error like below.

RangeError: Maximum call stack size exceeded
pkg/hub.js 249:10  __wbg_adapter_35
pkg/hub.js 206:20  real

This is because LLVM is currently broken with multivalue types(such as u128) on wasm32-unknown-unknown target of Rust. Related issues are listed below. This is not something that Rinf can solve, but an issue we should wait for a fix from LLVM.

Compiling webassembly module in release mode with rinf wasm --release is the workaround for now.

Steps to Reproduce

Write any code that uses u128 in Rust and run the app in debug mode.

System Information

Please provide the output from the command below, using markdown codeblock syntax.

rustc --version
flutter doctor
rustc 1.81.0 (eeb90cda1 2024-09-04)

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Version 10.0.22631.4169], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.6)
[√] Android Studio (version 2024.1)
[√] VS Code (version 1.93.1)
[√] Connected device (3 available)
[√] Network resources
• No issues found!
@CryZe
Copy link

CryZe commented Sep 20, 2024

Rust does not use the multivalue ABI and it's very hard to get it to do so (you need a custom target that you compile manually). Though to clarify further:

  1. extern "wasm" used to be a thing that technically could result in the multivalue ABI. extern "wasm" got removed.
  2. Rust 1.81 might still react to -C target-feature=+multivalue, but this was always broken without also rebuilding std, which requires nightly.
  3. On Beta (1.82) and Nightly it is no longer possible to get the multivalue ABI without a custom target.json.

@temeddix
Copy link
Member Author

temeddix commented Sep 20, 2024

Thank you for the details, maybe the cause might be something else. It does look like whenever using u128 makes the problem in debug mode. We're only using extern "C" without the +multivalue feature activated.

@temeddix temeddix changed the title Maximum call stack issue on the web Maximum call stack error on the web Sep 21, 2024
@poborin
Copy link
Contributor

poborin commented Oct 21, 2024

I had somewhat similar with FRB. Whenever I was using u8, I was getting a stack overflow exception: fzyzcjy/flutter_rust_bridge#2341

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants