expo-pixi
expo-pixi copied to clipboard
renderer.render() throwing error "EXGL: Invalid pixel data argument for gl.texImage2D()!" after building the app
I am getting the error: "EXGL: Invalid pixel data argument for gl. texImage2D()!" after building my expo application on Android. I have read the issues and handled the library versions and it still does not work.
I have also tried to get the Sketch component inside my code to understand which line throws the error.
The line that does not wotk out is the "this.renderer.render(this.stage);" which is called inside the onRead() method.
Here is my code:
` <GLView {...this.panResponder.panHandlers} onLayout={this.onLayoutSketch} key={"Expo.Sketch-" + global.__ExpoSketchId} style={styles.sketch} strokeColor={this.state.strokeColor} strokeWidth={this.state.strokeWidth} strokeAlpha={1} onChange={this.onChangeAsync} onReady={this.onReady} onContextCreate={this.onContextCreate} />
[...]
onLayoutSketch = ({
nativeEvent: {
layout: { width, height },
},
}) => {
try {
if (this.renderer) {
const scale = PixelRatio.get();
this.renderer.resize(width * scale, height * scale);
this.renderer._update();
}
} catch (e) {
console.log("onLayoutSketch error:", e);
}
};
[...]
onContextCreate = async context => {
try {
this.context = context;
this.stage = new PIXI.Container();
const getAttributes = context.getContextAttributes || (() => ({}));
context.getContextAttributes = () => {
const contextAttributes = getAttributes();
return {
...contextAttributes,
stencil: true,
};
};
this.renderer = PIXI.autoDetectRenderer(
context.drawingBufferWidth,
context.drawingBufferHeight,
{
context,
antialias: true,
backgroundColor: "transparent",
transparent: true,
autoStart: false,
},
);
this.renderer._update = () => {
try {
this.renderer.render(this.stage);
context.endFrameEXP();
} catch (e) {
console.log("_update error:", e);
}
};
// this.props.onReady && this.props.onReady(context);
this.onReady(context);
const { initialLines } = this.props;
if (initialLines) {
for (let line of initialLines) {
this.buildLine(line);
}
this.lines = initialLines;
}
} catch (e) {
console.log("onContextCreate error", e);
}
};
[...]
onReady = async context => {
const { layoutWidth, layoutHeight, points } = this.state;
try {
this.graphics = new PIXI.Graphics();
if (!this.stage) this.stage = new PIXI.Container();
if (layoutWidth && layoutHeight) {
let uriResolved = "";
const store = await helper.retrieveData(`${this.state.temporaryKey}`);
//alert(this.props.image)
if (this.props.link || store) {
let res = "";
if (this.props.link && !this.state.temporaryKey) {
this.checkAndCreateFolder(
`${FileSystem.documentDirectory}fotinha/${this.state.temporaryKey}.jpg`,
);
res = await FileSystem.downloadAsync(
this.props.image,
`${FileSystem.documentDirectory}fotinha/${this.state.temporaryKey}.jpg`,
);
} else {
res = store;
}
const fromUri = await AssetUtils.fromUriAsync(store ? res : res.uir);
fromUri.localUri = fromUri.uri;
uriResolved = await AssetUtils.resolveAsync(fromUri);
} else {
uriResolved = Fotovet;
}
const background = await PIXI.Sprite.fromExpoAsync(uriResolved);
background.width = layoutWidth * scaleR;
background.height = layoutHeight * scaleR;
this.stage.addChild(background);
this.renderer.render(this.stage);
context.endFrameEXP();
}
} catch (error) {
console.log("onReady error:", error);
}
};`
Can you guys help me out?
Same problem here after building Android APK...