UnsupportedOperationException: eglCreateWindowSurface()
I am using mapboxVersion = '7.0.0-beta.1' and started to see this particular crash randomly:
java.lang.UnsupportedOperationException: eglCreateWindowSurface() can only be called with an instance of Surface, SurfaceView, SurfaceHolder or SurfaceTexture at the moment.
at com.google.android.gles_jni.EGLImpl.eglCreateWindowSurface(EGLImpl.java:97)
at com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewRenderThread$EGLHolder.createSurface(TextureViewRenderThread.java:391)
at com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewRenderThread.run(TextureViewRenderThread.java:253)
My mapview is using texture mode <item name="mapbox_renderTextureMode">true</item>
Any idea why this crash is happening? The reproducibility is higher when I swipe the screen fast in a recycler view. In this issue I have some explanation about my usecase and setup.
I also see many of those [SurfaceTexture-0-5770-9] dequeueBuffer: BufferQueue has been abandoned error messages but they don't cause crash.
@ulusoyca that exception indicates that the surface is being recreated while in our sample code it doesn't get destroyed/recreated (only when leaving the activity). For reference, the code is here.
Atm not able to reproduce, happy to look more if you can provide an minimal reproducible example.
In my case and as in reference example onCreate() is only called when the viewholder is created and onDestroy when the activity is destroyed. I make sure that I am not calling these methods more than once according to logs. Here is an important question:
In what cases does the surface get recreated? Is the only reason for recreation calling onCreate() more than once?
I will send you a sample app where I can reproduce in case I cannot come up with a solution.
Me also getting crash reports, but I don't really get info enough to know how to reproduce it. Perhaps its helpful on this issue here.
Fatal Exception: java.lang.UnsupportedOperationException: eglCreateWindowSurface() can only be called with an instance of Surface, SurfaceView, SurfaceHolder or SurfaceTexture at the moment. at com.google.android.gles_jni.EGLImpl.eglCreateWindowSurface(EGLImpl.java:97) at com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewRenderThread$EGLHolder.createSurface(TextureViewRenderThread.java:391) at com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewRenderThread.run(TextureViewRenderThread.java:253)### Actual behavior
Configuration
Android versions:8 Device models: LGE Mapbox SDK versions:7.3.2
The exception is thrown in:
public static EGLSurface eglCreateWindowSurface(EGLDisplay dpy,
EGLConfig config,
Object win,
int[] attrib_list,
int offset){
Surface sur = null;
if (win instanceof SurfaceView) {
SurfaceView surfaceView = (SurfaceView)win;
sur = surfaceView.getHolder().getSurface();
} else if (win instanceof SurfaceHolder) {
SurfaceHolder holder = (SurfaceHolder)win;
sur = holder.getSurface();
} else if (win instanceof Surface) {
sur = (Surface) win;
}
EGLSurface surface;
if (sur != null) {
surface = _eglCreateWindowSurface(dpy, config, sur, attrib_list, offset);
} else if (win instanceof SurfaceTexture) {
surface = _eglCreateWindowSurfaceTexture(dpy, config,
win, attrib_list, offset);
} else {
throw new java.lang.UnsupportedOperationException(
"eglCreateWindowSurface() can only be called with an instance of " +
"Surface, SurfaceView, SurfaceTexture or SurfaceHolder at the moment, " +
"this will be fixed later.");
}
return surface;
}
In the case of our TextureView implementation it should have hit:
else if (win instanceof SurfaceTexture) {
surface = _eglCreateWindowSurfaceTexture(dpy, config,
win, attrib_list, offset);
} else {
..
}
The only explanation I'm seeing is that a null is passed as the win parameter. This SufaceTexture comes from:
/**
* Returns the {@link SurfaceTexture} used by this view. This method
* may return null if the view is not attached to a window or if the surface
* texture has not been initialized yet.
*
* @see #isAvailable()
*/
public SurfaceTexture getSurfaceTexture() {
return mSurface;
}
Which indicates it can return null if the view is ready yet to start initializing the window surface.
cc @LukasPaczos
Some stats from our fabric: 181 crashes from 144 users over the last 7 days:
HUAWEI - 36%
- Y7 25%
- nova 16%
- Honor 6A 13%
- P9 9%
- P9 lite 9%
- honor 6x 6%
- GT3 3%
- Honor 5C 3%
- P8 Lite 2%
- Honor 8 2%
- Honor 9 2%
- P10 lite 2%
motorola - 27%
- Moto G(4) Plus 90%
- Moto G (5th Gen) 8%
- Moto C Plus 2%
Xiaomi - 14%
- Redmi Note 4 96%
- MI MAX 4%
LENOVO - 4%
- VIBE K6 87%
- X1030x 13%
Android version: 7 - 95% 6 - 4% 5 - 1%