Revert "Revert "hwui: Fix a sporadic crash seen during CTS runs""

This reverts commit 3824da28d89164fac326ef7b6fde51f38292acb5.

Change-Id: I68619732d2991477db2a532ee16cc5a667c00b18