gl-react icon indicating copy to clipboard operation
gl-react copied to clipboard

uniforms Texture cannot read image assets in release build (Without metro server) - ract native

Open lakinduakash opened this issue 3 years ago • 1 comments

bug report

library version

"gl-react": "^4.0.1", "gl-react-native": "^4.0.1"

npm ls gl-react gl-react-dom gl-react-native gl-react-expo # Please run and paste the output of this

[email protected] /home/lakinduakash/revokex/projects/pets_mobile/Petstagram
├── [email protected] 
└─┬ [email protected] 
  └── [email protected] 

MyShader: {
        frag: `
      precision highp float;
      varying vec2 uv;

      uniform sampler2D inputImageTexture;
      uniform sampler2D inputImageTexture2;
     ..............
     ..............
export const Effect = ({children: inputImageTexture}) =>
    <Node
        shader={shaders.MyShader}
        uniforms={{
            inputImageTexture,
            inputImageTexture2: require('../assets/filters/map.png'),
        }}
    />;

<Surface style={{height: wp(100), width: wp(100)}} ref={image}>
        <Effect>
           {{uri:imgPath}}
       </Effect> 
</Surface>

Platform: Android 9.0 "react-native": "^0.62.0"

When metro server is enabled Shader is applied to the child image(uri:imgPath). But when debugger is disconnected from computer ,shader won't work.It just display empty background. Same issue in release build apk.

I assume the issue is in {inputImageTexture2: require('../assets/filters/map.png')} cannot get the image assets when metro server is disconnected. Without any external texture maps, shaders works without any issue even metro server is not running. Is there any other way to refer image assets. React native won't add those images into android apk's asset folder. I also manually put those images into asset folder. None of them worked. I identified react native compress those images and put them into android's resource folder.

Expected behavior

Apply textures external image sources in all variants of build. Even without metro server

Actual behavior

External image textures won't apply when metro server is disconnected and release build also

Steps to reproduce the behavior

  • Create any shader script that apply external image.
  • Then in Node's uniform from give the image assets with require() tag.
  • Build release apk or disconnect from metro server, restart the app

lakinduakash avatar Jul 10 '20 18:07 lakinduakash

@lakinduakash Have you found a solution? It's now August 2023 and I have the same issue, it's killing me I've been trying to fix this for a week now. I've tried preloading the image, manually adding it in the assets/drawable... iOS works fine in release as well, but I can't build my Android Release

maxximee avatar Aug 21 '23 05:08 maxximee