Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6b3c4113 authored by John Reck's avatar John Reck
Browse files

Fix NPE in layer destruction

 Bug: 13111945
 Fixes an issue where a layer is destroyed after the GLRenderer
 lost its Surface. Instead just check that the context we want is
 current regardless of the active surface

Change-Id: I6537e6232b5c667b218b896ed5ef390fbe956344
parent c4f6c351
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -499,12 +499,17 @@ public class GLRenderer extends HardwareRenderer {
        mAttachedLayers.add(hardwareLayer);
    }

    boolean hasContext() {
        return sEgl != null && mEglContext != null
                && mEglContext.equals(sEgl.eglGetCurrentContext());
    }

    @Override
    void onLayerDestroyed(HardwareLayer layer) {
        if (mGlCanvas != null) {
            mGlCanvas.cancelLayerUpdate(layer);
        }
        if (Looper.myLooper() == Looper.getMainLooper() && validate()) {
        if (hasContext()) {
            long backingLayer = layer.detachBackingLayer();
            nDestroyLayer(backingLayer);
        }