• Wed 2019.01.30

    Until a week ago, for the last three months, I had the following block of code inside a constructor creating several flat strings without fail.

        var nArySizeRGB = options.numPixels * 3;
      
        var strg = E.toString({data : 0, count : 256});
        var strd = E.toString({data : 0, count : nArySizeRGB});
        var strr = E.toString({data : 0, count : nArySizeRGB});
        var strb = E.toString({data : 0, count : nArySizeRGB});
        var strc = E.toString({data : 0, count : nArySizeRGB});
        var strf = E.toString({data : 0, count : nArySizeRGB});
    
        this.ad = new Uint8ClampedArray(E.toArrayBuffer(strd))­;
        this.ar = new Uint8ClampedArray(E.toArrayBuffer(strr))­;
        this.ab = new Uint8ClampedArray(E.toArrayBuffer(strb))­;
        this.ac = new Uint8ClampedArray(E.toArrayBuffer(strc))­;
        this.af = new Uint8ClampedArray(E.toArrayBuffer(strf))­;
        this.ag = new Uint8ClampedArray(E.toArrayBuffer(strg))­;
    



    Now, not all the strings get created.

    typeof: string len: 256
    Uncaught Error: Unsupported first argument of type undefined
     at line 4 col 192
    ...Array(E.toArrayBuffer(strb));this.ac=­new Uint8ClampedArray(E...
    


    I peppered the source with console.log statements and see three strings are created before the inevitable

    [L270] nArySizeRGB 180
    strg typeof: string len: 256
    strd typeof: string len: 180
    strr typeof: string len: 180
    Uncaught Error: Cannot read property 'length' of undefined
     at line 4 col 115
    ..."+typeof strb+" len: "+strb.length);var strc=E.toString({dat...
    


    Re-Reading:

    http://www.espruino.com/Performance

    I see that creating them takes time. There doesn't appear to be a solution to try, should that time duration block subsequent code execution.

    I have tried reset(true), closing and re-opening the WebIDE and even powering down the Pico.

    Is there a preferred way to somehow add a delay between each creation request and only advance after that request was successful?


    >pm()
    { "free": 1491, "usage": 3609, "total": 5100, "history": 1332,
    
    >process.env
    ={
      VERSION: "2v00.103",
      GIT_COMMIT: "df8a910",
      BOARD: "PICO_R1_3",
    
About

Avatar for Robin @Robin started