-
-
Notifications
You must be signed in to change notification settings - Fork 296
Description
Forum post here which I will copy the relevant pieces next:
From the trace call, I can see the problem is the background() function call in OPENGL mode. I am able to reproduce the problem with the following MCVE (plz ensure image is in the data folder):
import android.os.Environment;
import android.os.Build ;
import android.app.Activity;
import android.content.Context;
PImage back;
void setup(){
size(displayWidth, displayHeight, P3D);
back = loadImage("bg.jpg");
}
void draw(){
background(back); <----NPE!
//set(0,0,back); <----NPE!
//image(back,0,0,width,height); <--It works
}
Notice that when using P3D:
- Either background() or set() throws an NPE and App crashes
- It works normally if one uses image() instead,
Using the default renderer, you can use either background/set/image and you won't have any problem. I tested this using Win10, AM 4.0.1 and P3.3.6 on SG8 Nougat.
Back trace output next based on background():
//FATAL EXCEPTION: GLThread 181069
//Process: processing.test.sketch_180219b, PID: 7447
//java.lang.NullPointerException: src == null
// at java.lang.System.arraycopy(Native Method)
// at processing.opengl.PGraphicsOpenGL.setImpl(Unknown Source)
// at processing.core.PImage.set(Unknown Source)
// at processing.opengl.PGraphicsOpenGL.backgroundImpl(Unknown Source)
// at processing.core.PGraphics.background(Unknown Source)
// at processing.core.PApplet.background(Unknown Source)
// at processing.test.sketch_180219b.sketch_180219b.draw(sketch_180219b.java:123)
// at processing.core.PApplet.handleDraw(Unknown Source)
// at processing.opengl.PSurfaceGLES$RendererGLES.onDrawFrame(Unknown Source)
// at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1562)
// at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1262)
Back trace output next based on set():
//FATAL EXCEPTION: GLThread 183761
//Process: processing.test.sketch_180219b, PID: 3877
//java.lang.NullPointerException: src == null
// at java.lang.System.arraycopy(Native Method)
// at processing.opengl.PGraphicsOpenGL.setImpl(Unknown Source)
// at processing.core.PImage.set(Unknown Source)
// at processing.core.PApplet.set(Unknown Source)
// at processing.test.sketch_180219b.sketch_180219b.draw(sketch_180219b.java:132)
// at processing.core.PApplet.handleDraw(Unknown Source)
// at processing.opengl.PSurfaceGLES$RendererGLES.onDrawFrame(Unknown Source)
// at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1562)
// at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1262)
These lines are of interest based on the trace:
https://github.com/processing/processing-android/blob/master/core/src/processing/opengl/PGraphicsOpenGL.java#L5798
https://github.com/processing/processing-android/blob/master/core/src/processing/core/PApplet.java#L9670
https://github.com/processing/processing-android/blob/master/core/src/processing/opengl/PGraphicsOpenGL.java#L5787
https://github.com/processing/processing-android/blob/master/core/src/processing/opengl/PGraphicsOpenGL.java#L5474
Kf