Expo.GLView readPixels return array of zeros

#1

I think my problem is similar to this post, which was never solved:

I tried to follow this snack that I found, but it has the same issue (I exported to XDE as the snack itself reports “No experience found”)
https://snack.expo.io/@bacon/get-image-data-rgba-expo-+-exgl

My code is like the following:

<Expo.GLView
        ref={(ref) => this._glView = ref}
        style={{ flex: 1 }}
        onContextCreate={this._onGLContextCreate}
      />
_onGLContextCreate = async (gl) => {

      // Some code to create AR scene, not shown here

      let animate = () => {
      requestAnimationFrame(animate);
      renderer.render(scene, camera);
      gl.endFrameEXP();

      //Finger detection, run every 10 drawing cycles
      if(cycle_idx === 0){
        let pixels = new Uint8Array(width * height * 4);
        console.debug(pixels[4] + " " + pixels[5] + " " + pixels[6] + " " + pixels[7]);
        console.debug(width + " " + height);
        gl.readPixels(0, 0, width, height, gl.RGBA_INTEGER, gl.UNSIGNED_BYTE, pixels);
        //contrusct an ImageData object from pixels and analyze
        //TODO: somehow the readPixels return all 0 values, interesting
        console.debug(pixels[240] + " " + pixels[241] + " " + pixels[242] + " " + pixels[7]);
        HGD.frameAnalyzer(width, height, pixels);
      }
    }
    animate();   
  }
}

Additionally, this was part of a project that is using the Expo ARkit.
I would really appreciate any help, thank you in advance.

#2

Hey Matt, thanks for brining this to our attention!
We’re tracking the issue here: https://github.com/expo/expo/issues/1437

1 Like
closed #3

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.