Strilanc / Quirk

A drag-and-drop quantum circuit simulator that runs in your browser. A toy for exploring and understanding small quantum circuits.
http://algassert.com/quirk
Apache License 2.0
933 stars 158 forks source link

Crash on mobile #507

Open gustav-langer opened 11 months ago

gustav-langer commented 11 months ago

This is a modified version of Quirk, used for this online course. It runs fine on my laptop (Windows 10, Microsoft Edge), but is unusable on my phone (Android 8, Chrome)

Error Message:


Defaulted to NaN results. Computing circuit values failed.

URL https://www.quantum-quest.org/quirky/QuirkyQuest1.html

BROWSER Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36 Netscape 5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36

RECOVERY DETAILS {"circuitDefinition": {"cols": []}}

ERROR OBJECT Error: WebGLShader: Shader compile failed. Info: 0:1: S0033: no default precision defined for function 's1605'� Source: precision highp float; precision highp int;

    ///////////// makeFloatCoderOutput2 ////////////
    vec2 outputFor(float k);

    uniform vec2 _gen_output_size;
    uniform float _gen_secret_half;

    float len_output() {
        return _gen_output_size.x * _gen_output_size.y;
    }

//////// body ////////

uniform float state;
vec2 outputFor(float k) {
    return vec2(float(k == state), 0.0);
}

void main() { vec2 xy = gl_FragCoord.xy - vec2(_gen_secret_half, _gen_secret_half); float k = xy.y * _gen_output_size.x + xy.x;

        vec2 v = outputFor(k);

        gl_FragColor = vec4(v.x, v.y, 0.0, 0.0);
    }

ERROR LOCATION Error: WebGLShader: Shader compile failed. Info: 0:1: S0033: no default precision defined for function 's1605'� Source: precision highp float; precision highp int;

    ///////////// makeFloatCoderOutput2 ////////////
    vec2 outputFor(float k);

    uniform vec2 _gen_output_size;
    uniform float _gen_secret_half;

    float len_output() {
        return _gen_output_size.x * _gen_output_size.y;
    }

//////// body ////////

uniform float state;
vec2 outputFor(float k) {
    return vec2(float(k == state), 0.0);
}

void main() { vec2 xy = gl_FragCoord.xy - vec2(_gen_secret_half, _gen_secret_half); float k = xy.y * _gen_output_size.x + xy.x;

        vec2 v = outputFor(k);

        gl_FragColor = vec4(v.x, v.y, 0.0, 0.0);
    }
at Function.compileShader (https://www.quantum-quest.org/quirky/QuirkyQuest1.html:317:540743)
at new i (https://www.quantum-quest.org/quirky/QuirkyQuest1.html:317:538993)
at $traceurRuntime.createClass.initializedValue.initializer (https://www.quantum-quest.org/quirky/QuirkyQuest1.html:317:537819)
at $traceurRuntime.createClass.initializedValue.initializedValue (https://www.quantum-quest.org/quirky/QuirkyQuest1.html:317:535541)
at e.renderToFunc (https://www.quantum-quest.org/quirky/QuirkyQuest1.html:317:538149)
at e.renderTo (https://www.quantum-quest.org/quirky/QuirkyQuest1.html:317:531249)
at e.renderToFunc (https://www.quantum-quest.org/quirky/QuirkyQuest1.html:317:519273)
at e.renderTo (https://www.quantum-quest.org/quirky/QuirkyQuest1.html:317:531249)
at e._renderToElseDealloc (https://www.quantum-quest.org/quirky/QuirkyQuest1.html:317:531414)
at e.toVec2Texture (https://www.quantum-quest.org/quirky/QuirkyQuest1.html:317:532672)
gustav-langer commented 11 months ago

Update: I get the same issue with the unmodified Quirk version listed on this repo, http://algassert.com/quirk .

Strilanc commented 11 months ago

This crash makes no sense to me, as the first line of the shader source that's failing to compile specifies the precision that the error says it is not specifying. Some searching on the internet suggests that maybe I need to check for GL_FRAGMENT_PRECISION_HIGH to use precision highp float, but if high precision isn't available the simulation is very likely to return incorrect results (precision affects not just floats but index calculations used for picking what data to combine). So I suspect the fix for this issue would look like Quirk saying "Oh no! You need a newer android for this to work!" rather than actually working...