OSDN Git Service

Call validateDisplay() when skipping frames
authorSteven Thomas <steventhomas@google.com>
Wed, 26 Apr 2017 21:34:01 +0000 (14:34 -0700)
committerSteven Thomas <steventhomas@google.com>
Wed, 26 Apr 2017 22:15:56 +0000 (15:15 -0700)
commit0af4b9f88a48a6ecc705b4a8cec3d3ba24c53ead
tree8a0c0c796bd685f39dab51bdaaecbdaf685326d4
parent0e9dcf6657a9101b02e1e1182f6fe3d652679a9a
Call validateDisplay() when skipping frames

Layer management was getting screwed up in vr flinger in the following
scenario:

1. In frame X, post a new buffer to layer L.

2. Decide to skip frame X (e.g. because we're behind our target
schedule).

3. In frame X+1, delete layer L.

When we skip the frame in step 2, we weren't calling validateDisplay()
or presentDisplay() on the hardware composer, so the composer's internal
command queue wasn't being flushed. When we called validateDisplay() for
frame X+1 the update buffer call from frame X would be run, referencing
the deleted layer L, causing a crash.

Now we always call validateDisplay() when we change the layer state,
even if we decide to skip the frame.

I also added code to explicitly clear the Composer object's internal
command buffer when we transfer control from surface flinger to vr
flinger and back. There were certain cases where there could be commands
left in the command buffer after the display handoff.

Bug: 37159844

Test: I used an app switcher script that quickly switches vr apps, which
would consistently trigger the setLayerBuffer crash. I confirmed with
this CL applied I can run the app switcher until surface flinger runs
out of file descriptors (that's a separate bug), and I never see the
setLayerBuffer crash. I also confirmed from the log output there are no
additional hardware composer errors.

Change-Id: I85832b87f393754dc6b034eb38f2937d7b58ed74
libs/vr/libvrflinger/hardware_composer.cpp
services/surfaceflinger/DisplayHardware/ComposerHal.cpp
services/surfaceflinger/DisplayHardware/ComposerHal.h