DO NOT MERGE: Fix testVirtualDisplayRecycles fail for no thread racing protection for mNumTextureUpdated

testVirtualDisplayRecycles some time failed in function updateTexImageIfNecessary for numTextureUpdated < 0.
The reason is there is no protection for mNumTextureUpdated. The issue happens in following sequence:
1. recreateWindows is called and DO_RECREATE_WINDOWS message is sent to CompositionHandler
2. onFrameAvailabe is called for previous GlWindow content update, mNumTextureUpdated is increased and
   DO_RENDERING message is sent to CompositionHandler
3. DO_RECREATE_WINDOWS message is handled and mNumTextureUpdated reset to 0 for mTopWindow is recreated.
4. DO_RENDERING message is handled, mNumTextureUpdated.getAndDecrement return -1, then case failed.

how to fix: Send DO_RENDERING message w/ mTopWindow as obj parameter, do nothing if message.obj != mTopWindow
            when handle the message.

Change-Id: I3ee2128149f0bb67ce640212414ab95aeab24ab1
Signed-off-by: Hurri Lu <>
1 file changed