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

Local count too large #478

Closed
fils opened this issue Mar 10, 2019 · 10 comments
Closed

Local count too large #478

fils opened this issue Mar 10, 2019 · 10 comments

Comments

@fils
Copy link

fils commented Mar 10, 2019

Description

bug-report
In the example "showcase" and a few others (like "dashboard") I can not get them to run. Others like the custom_components work fine

Expected Results

to be able to load the page....

Actual Results

Uncaught (in promise) CompileError: AsyncCompilation: Compiling wasm function "wasm-function[42950]" failed: local count too large @+11247460

Context (Environment)

  • Rust: rustc 1.35.0-nightly (26b4cb484 2019-03-09)

  • yew: v0.7.0

  • target:

  • cargo-web: cargo-web 0.6.23

  • browser if relevant
    I get the error in both Chrome and Firefox Dev Edition.
    Chrome: Version 72.0.3626.121 (Official Build) (64-bit) Linux
    FF: 66.0b14 (64-bit) Linux

Any help or guidance appreciated!
Any further info I can provide to help with this let me know!

@mokeyish
Copy link

I got this problem too.

@iammichiel
Copy link

iammichiel commented Mar 19, 2019

Same here. Total guess but I think it would be some kind of recursion problem.
My code is not an example sample but I can single it out to a single line.

self.task = Some(self.fetch_service.fetch(get_request, handler));

The code is quite explicit and partially copied from https://github.com/DenisKolodin/yew/blob/a6a73948331ae50a9b6a196c721f21b4a39b52d1/examples/dashboard/src/lib.rs

Once the line is commented, every works fine/compiles.
Will try to dig a little further if I can discover something.

@nbrr
Copy link

nbrr commented Mar 19, 2019

See #455, at the moment the fix is to compile with --release.

@Th3Whit3Wolf
Copy link

It seems it would be beneficial to add this to the README in the root of this repo or in a README in the example directory that require this to function.

@matiu2
Copy link

matiu2 commented Jul 1, 2019

For me it prints this in the console in the brave browser:

Uncaught (in promise) CompileError: WebAssembly.compile(): Compiling function #4181:"_ZN4http6header4name9parse_hdr17h241b60d2c73f294fE" failed: local count too large @+1056340

After some inspector cluseuing I think the fault lies with this function in the http library:

https://github.com/hyperium/http/blob/master/src/header/name.rs#L1061

It has a lot of heavy macro usage, and a big match statement.

@matiu2
Copy link

matiu2 commented Jul 1, 2019

I ran it through: cargo expand < name.rs and it has a bunch of lines like this, which I expect will be the cause:

this:

if eq!(b == b'c' b'o' b'n' b't' b'e' b'n' b't' b'-' b's' b'e' b'c' b'u' b'r' b'i' b't' b'y' b'-' b'p' b'o' b'l' b'i' b'c' b'y' b'-' b'r' b'e' b'p' b'o' b'r' b't' b'-' b'o' b'n' b'l' b'y') { Ok(ContentSecurityPolicyReportOnly.into())
.. expands to something like this:

                    if b[0] == b'c'
                        && b[0 + 1] == b'o'
                        && b[0 + 1 + 1] == b'n'
                        && b[0 + 1 + 1 + 1] == b't'
                        && b[0 + 1 + 1 + 1 + 1] == b'e'
                        && b[0 + 1 + 1 + 1 + 1 + 1] == b'n'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1] == b't'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1] == b'-'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1] == b's'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1] == b'e'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1] == b'c'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1] == b'u'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1] == b'r'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1] == b'i'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1] == b't'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1] == b'y'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'-'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'p'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'o'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'l'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'i'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'c'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'y'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'-'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'r'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'e'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'p'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'o'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'r'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b't'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'-'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'o'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'n'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'l'
                        && b[0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1]
                            == b'y'
                    {
                        Ok(ContentSecurityPolicyReportOnly.into())

I guess that with optimisation turned off it doesn't pre-calculate all the addition and makes wasm do it.

matiu2 added a commit to matiu2/http that referenced this issue Jul 1, 2019
Advantages:

 1. Shorter code
 2. More rusty and less macroy
 3. It should work in wasm now untested and make yew users happier
    yewstack/yew#478
@matiu2
Copy link

matiu2 commented Jul 1, 2019

I have created a pull request with the http project that fixes this: hyperium/http#324

Until this all gets accepted and merged, you can use my temporary fork of yew in debug mode: https://github.com/matiu2/yew

matiu2 added a commit to matiu2/http that referenced this issue Jul 9, 2019
Advantages:

 1. Shorter code
 2. More rusty and less macroy
 3. It should work in wasm now untested and make yew users happier
    yewstack/yew#478
matiu2 added a commit to matiu2/http that referenced this issue Jul 9, 2019
Advantages:

 1. Shorter code
 2. More rusty and less macroy
 3. It should work in wasm now untested and make yew users happier
    yewstack/yew#478
matiu2 added a commit to matiu2/http that referenced this issue Jul 9, 2019
Advantages:

 1. Shorter code
 2. More rusty and less macroy
 3. It should work in wasm now untested and make yew users happier
    yewstack/yew#478
@matiu2
Copy link

matiu2 commented Jul 29, 2019

This landed in http trunk now. I guess once they do a new stable release, it'll be fixed for everyone here too: hyperium/http#324

@matiu2
Copy link

matiu2 commented Jul 31, 2019

I can confirm this is working now since about 5 days ago, when http released https://github.com/hyperium/http/releases/tag/v0.1.18

To test, just run the dashboard example in non-release mode and download something through http.

This issue can be closed.

@jstarry
Copy link
Member

jstarry commented Aug 3, 2019

Great, thanks @matiu2!

@jstarry jstarry closed this as completed Aug 3, 2019
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

7 participants