@@ -1525,30 +1525,6 @@ void setSurfaceTexture(HardwareLayer layer, SurfaceTexture surfaceTexture) {
15251525 ((GLES20TextureLayer ) layer ).setSurfaceTexture (surfaceTexture );
15261526 }
15271527
1528- @ Override
1529- void destroyLayers (View view ) {
1530- if (view != null && isEnabled () && checkCurrent () != SURFACE_STATE_ERROR ) {
1531- if (mCanvas != null ) {
1532- mCanvas .clearLayerUpdates ();
1533- }
1534- destroyHardwareLayer (view );
1535- GLES20Canvas .flushCaches (GLES20Canvas .FLUSH_CACHES_LAYERS );
1536- }
1537- }
1538-
1539- private static void destroyHardwareLayer (View view ) {
1540- view .destroyLayer (true );
1541-
1542- if (view instanceof ViewGroup ) {
1543- ViewGroup group = (ViewGroup ) view ;
1544-
1545- int count = group .getChildCount ();
1546- for (int i = 0 ; i < count ; i ++) {
1547- destroyHardwareLayer (group .getChildAt (i ));
1548- }
1549- }
1550- }
1551-
15521528 @ Override
15531529 boolean safelyRun (Runnable action ) {
15541530 boolean needsContext = true ;
@@ -1573,6 +1549,35 @@ boolean safelyRun(Runnable action) {
15731549 return true ;
15741550 }
15751551
1552+ @ Override
1553+ void destroyLayers (final View view ) {
1554+ if (view != null ) {
1555+ safelyRun (new Runnable () {
1556+ @ Override
1557+ public void run () {
1558+ if (mCanvas != null ) {
1559+ mCanvas .clearLayerUpdates ();
1560+ }
1561+ destroyHardwareLayer (view );
1562+ GLES20Canvas .flushCaches (GLES20Canvas .FLUSH_CACHES_LAYERS );
1563+ }
1564+ });
1565+ }
1566+ }
1567+
1568+ private static void destroyHardwareLayer (View view ) {
1569+ view .destroyLayer (true );
1570+
1571+ if (view instanceof ViewGroup ) {
1572+ ViewGroup group = (ViewGroup ) view ;
1573+
1574+ int count = group .getChildCount ();
1575+ for (int i = 0 ; i < count ; i ++) {
1576+ destroyHardwareLayer (group .getChildAt (i ));
1577+ }
1578+ }
1579+ }
1580+
15761581 @ Override
15771582 void destroyHardwareResources (final View view ) {
15781583 if (view != null ) {
0 commit comments