[View] Clear Hardware-Layers before system destroys HardwareRenderer​.

Symptom: Sometimes HardwareLayer display is corrupted.

Root Cause: In some cases, ViewRootImpl destroys HardwareRenderer​ without
clearing HardwareLayers in the view hirarchy. If the system trims memory fully
and kill the glContext at the same time, HardwareLayer may corrupt.

Solution: Clear Hardware-Layers before system destroys HardwareRenderer​.

Reproduce steps: Modify the cache's trim memory mechanism to make it easier to
trim fully, HardwareLayers implemented in app will easily be corrupted.
Modification of the cache is not required but make it easier to reproduce.

Change-Id: If57c802cdacf8dc37cbbcc199e74f9482834f981
This commit is contained in:
henry.uh_chen
2014-07-18 15:11:18 +08:00
parent 152d9e6128
commit a199720190

3
core/java/android/view/ViewRootImpl.java Normal file → Executable file
View File

@@ -1565,6 +1565,9 @@ public final class ViewRootImpl implements ViewParent,
// Our surface is gone
if (mAttachInfo.mHardwareRenderer != null &&
mAttachInfo.mHardwareRenderer.isEnabled()) {
// Destroy hardware layers before hardware renderer is destroyed
mAttachInfo.mHardwareRenderer.destroyHardwareResources(mView);
mAttachInfo.mHardwareRenderer.destroy(true);
}
} else if (surfaceGenerationId != mSurface.getGenerationId() &&