History log of /frameworks/native/libs/vr/libvrflinger/display_service.h
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
bfe46a053be03836a060853711b467ed5e10affa 16-Feb-2018 Steven Thomas <steventhomas@google.com> Support external display rendering in vr flinger

Add support for external displays to vr flinger, hidden behind a system
property until we're ready to use it. To turn it on for testing:

$ adb shell setprop persist.vr.use_external_display 1

With external display support turned on and an external display
connected, all output is redirected to the external display, and we
switch to the external display's vsync.

Bug: 75047963

Test: Most of the testing was done on a Polaris, which now supports
external display hotplugging.

- Tested external display connect/disconnect while the device was
donned.

- Tested external display connect/disconnect while doffed.

- Verified booting with the external display connected doesn't cause the
device to crash, although we don't seem to get a hotplug event for the
external display until the cable is disconnected and reconnected, so
we output to the primary display at first.

- Did some basic testing on a Walleye to confirm vr behavior there is
unchanged.

- Verified the external display is ignored when the sysprop is unset.

Change-Id: I3d3f40e276d354551fc1c577b9392709398ad96e
/frameworks/native/libs/vr/libvrflinger/display_service.h
af33627a44279bad668af4f7466309b2e6f152a8 05-Jan-2018 Steven Thomas <steventhomas@google.com> Have vr flinger take the display after boot on standalones

1. Have vr flinger request the display immediately after boot finishes
on standalones, to prevent incorrectly showing normal 2d content from
surface flinger on the display during startup.

2. If we don't get any surfaces to show for a while after boot finishes,
turn the display off. This should only occur if VrCore is misbehaving
somehow.

Bug: 65742855

Test: - Verified no flickering in the boot anim.

- Verified that if no surfaces are created the display is turned off.

Change-Id: Ibfcd97101334e552d1d562fe4ae9c36877b44397
/frameworks/native/libs/vr/libvrflinger/display_service.h
6e8f706c21a01d6a1225e86972ff432bba5f0106 22-Nov-2017 Steven Thomas <steventhomas@google.com> Fix usage of HWC_DISPLAY_PRIMARY in vr flinger

The hardware composer functions require display ids obtained from the
onHotplug() composer callback. Our vr flinger code was supplying
HWC_DISPLAY_PRIMARY as the primary display id, which is incorrect. The
HWC_DISPLAY_* values are used for representing the display type, not the
display id. The code worked anyway because most hardware composers
always use 0 as the primary display id, which happens to be the same
value as HWC_DISPLAY_PRIMARY. The emulator uses 1 as the primary display
id though, which exposed the bug.

This CL changes the vr flinger code to get the display id from the
onHotplug() composer callback, and uses that value when talking to
hardware composer, instead of HWC_DISPLAY_PRIMARY. This matches the
behavior of surface flinger.

Bug: 69631196

Test: Verified the vr flinger code path works as expected on phones and
standalones.

Change-Id: Ia691941d0eafaa1f89e0ee81a4ae27fdef5a57cf
/frameworks/native/libs/vr/libvrflinger/display_service.h
94e35b93537c7f9da018688ac8a8ba87f4689915 27-Jul-2017 Steven Thomas <steventhomas@google.com> Use a separate hwcomposer hidl instance for vr flinger

Improve robustness of vr flinger <--> surface flinger switching by
having vr flinger use a separate hardware composer hidl instance instead
of sharing the instance with surface flinger. Sharing the hardware
composer instance has proven to be error prone, with situations where
both the vr flinger thread and surface flinger main thread would write
to the composer at the same time, causing hard to diagnose
crashes (b/62925812).

Instead of sharing the hardware composer instance, when switching to vr
flinger we now delete the existing instance, create a new instance
directed to the vr hardware composer shim, and vr flinger creates its
own composer instance connected to the real hardware composer. By
creating a separate composer instance for vr flinger, crashes like the
ones found in b/62925812 are no longer impossible.

Most of the changes in this commit are related to enabling surface
flinger to delete HWComposer instances cleanly. In particular:

- Previously the hardware composer callbacks (which come in on a
hwbinder thread) would land in HWC2::Device and bubble up to the
SurfaceFlinger object. But with the new behavior the HWC2::Device
might be dead or in the process of being destroyed, so instead we have
SurfaceFlinger receive the composer callbacks directly, and forward
them to HWComposer and HWC2::Device. We include a composer id field in
the callbacks so surface flinger can ignore stale callbacks from dead
composer instances.

- Object ownership for HWC2::Display and HWC2::Layer was shared by
passing around shared_ptrs to these objects. This was problematic
because they referenced and used the HWC2::Device, which can now be
destroyed when switching to vr flinger. Simplify the ownership model
by having HWC2::Device own (via unique_ptr<>) instances of
HWC2::Display, which owns (again via unique_ptr<>) instances of
HWC2::Layer. In cases where we previously passed std::shared_ptr<> to
HWC2::Display or HWC2::Layer, instead pass non-owning HWC2::Display*
and HWC2::Layer* pointers. This ensures clean composer instance
teardown with no stale references to the deleted HWC2::Device.

- When the hardware composer instance is destroyed and the HWC2::Layers
are removed, notify the android::Layer via a callback, so it can
remove the HWC2::Layer from its internal table of hardware composer
layers. This removes the burden to explicitly clear out all hardware
composer layers when switching to vr flinger, which has been a source
of bugs.

- We were missing an mStateLock lock in
SurfaceFlinger::setVsyncEnabled(), which was necessary to ensure we
were setting vsync on the correct hardware composer instance. Once
that lock was added, surface flinger would sometimes deadlock when
transitioning to vr flinger, because the surface flinger main thread
would acquire mStateLock and then EventControlThread::mMutex, whereas
the event control thread would acquire the locks in the opposite
order. The changes in EventControlThread.cpp are to ensure it doesn't
hold a lock on EventControlThread::mMutex while calling
setVsyncEnabled(), to avoid the deadlock.

I found that without a composer callback registered in vr flinger the
vsync_event file wasn't getting vsync timestamps written, so vr flinger
would get stuck in an infinite loop trying to parse a vsync
timestamp. Since we need to have a callback anyway I changed the code in
hardware_composer.cpp to get the vsync timestamp from the callback, as
surface flinger does. I confirmed the timestamps are the same with
either method, and this lets us remove some extra code for extracting
the vsync timestamp that (probably) wasn't compatible with all devices
we want to run on anyway. I also added a timeout to the vysnc wait so
we'll see an error message in the log if we fail to wait for vsync,
instead of looping forever.

Bug: 62925812

Test: - Confirmed surface flinger <--> vr flinger switching is robust by
switching devices on and off hundreds of times and observing no
hardware composer related issues, surface flinger crashes, or
hardware composer service crashes.

- Confirmed 2d in vr works as before by going through the OOBE flow on a
standalone. This also exercises virtual display creation and usage
through surface flinger.

- Added logs to confirm perfect layer/display cleanup when destroying
hardware composer instances.

- Tested normal 2d phone usage to confirm basic layer create/destroy
functionality works as before.

- Monitored surface flinger file descriptor usage across dozens of
surface flinger <--> vr flinger transitions and observed no file
descriptor leaks.

- Confirmed the HWC1 code path still compiles.

- Ran the surface flinger tests and confirmed there are no new test
failures.

- Ran the hardware composer hidl in passthrough mode on a Marlin and
confirmed it works.

- Ran CTS tests for virtual displays and confirmed they all pass.

- Tested Android Auto and confirmed basic graphics functionality still
works.

Change-Id: I17dc0e060bfb5cb447ffbaa573b279fc6d2d8bd1
/frameworks/native/libs/vr/libvrflinger/display_service.h
99c2d73588dad4a4d12a17d37354237b8c11a16a 08-Jun-2017 Corey Tabaka <eieio@google.com> Move global buffer ops to VR display service.

The original home for these ops was the VR display manager service,
which is a protected singleton service that may only have one client.
Since more than one service needs to create global buffers, move these
ops to the display service. They are already protected by permission
checks.

Bug: 62424911
Test: dvr_api-test passes
Change-Id: Ia2f57fdf8a5258b52a652935d160e90db0f1cf9e
/frameworks/native/libs/vr/libvrflinger/display_service.h
bcb03d005a4ccca20a0723f087e90e8b503b4848 23-May-2017 Hendrik Wagenaar <hendrikw@google.com> Move dvr config data from display manager to display service

* The limitation of creating only one display manager client
is preventing config data access on multiple threads

Bug: 38269706
Test: DvrDisplayManagerTest::ConfigurationData
Change-Id: Ifc14cf0dd79248aea6367aca70c4e4f8359a25de
/frameworks/native/libs/vr/libvrflinger/display_service.h
954796e27e89209b38b35779949c243bec490c28 11-May-2017 John Bates <jbates@google.com> Add shmem config buffer to libvrflinger

This allows VrCore to configure some tunable behaviors
of libvrflinger.

- Added dvrDisplayManagerDeleteNamedBuffer for testing config buffer
creation.
- Added tests for named buffers, including one for the config buffer.
- Added IsValid to broadcast_ring to avoid tracking redundant state
externally.

Bug: 38193993
Test: Run dvr_named_buffer-test
Change-Id: I52722dd314233b5bea1ca6377c14b5c856825746
/frameworks/native/libs/vr/libvrflinger/display_service.h
36d23803882c64b1006cd3b8a47e00a4193a9b49 16-May-2017 Okan Arikan <okana@google.com> Int key for the named buffers.

Also, rename them to global buffers from named buffers.

Bug: 38320428
Test: Run frameworks/native/libs/vr/libdvr/tests on device
Change-Id: I2109aea77e35f2ccd8055208058df4b7287c1d5e
/frameworks/native/libs/vr/libvrflinger/display_service.h
2251d822dac2a96aad4184a6fdc2690f0a58af7c 21-Apr-2017 Corey Tabaka <eieio@google.com> Remove the VR compositor from the framework.

Remove the VR compositor framework and enable out-of-process VR composition
in VrCore.

This CL seems large due to the ripple effect of changing the VrFlinger
API and protocol types. There are three major modules that require
concurrent changes:
1. Protocol definitions and low-level VrFlinger API in libdisplay.
* Additional changes needed to keep old interfaces working for
a short time while replacing the dependent code (dvrGraphics*).
2. VrFlinger service implementation changes to support VrCore compositor
and the removal of the internal compositor.
3. Changes to libdvr platform library API due to changes in #1 and #2.

Because of the nature of the interdependence of types and other defs it is
difficult to break this CL into smaller chunks. However, review of the three
major modules (libdisplay, libdvr, and libvrflinger) may be done separately
to ease the mental burden on reviewers.

Change Summary:
- Remove obsolete screenshot service. VR screenshots will be implemented
by VrCore.
- Update display protocol definitions for changes in VrFlinger service
requirements. The majority of the changes in libdisplay are a
consequence of these protocol and service changes.
- Update VrFlinger to support two kinds of surfaces:
1. Application - use by VR apps.
2. Direct - used by VrCore (protected by permission check).
- Remove VrFlinger internal compositor and GL context.
- Remove obsolete debug console.
- Update VrFlinger hardware composer interface to handle direct
surfaces only, removing the concept of GPU (compositor) layers.
- Update display manager to expose access to application surface info
to VrCore (protected by permission check).
- Update libdvr platform library interfaces for changes to VrFlinger
API / protocol.
- Clean up libdvr API struct setup using a common include.
- Add C++ header-only helpers for DVR platform library opaque types.

Bug: 36401174
Test: Build; run VrFlinger display test tool.
Change-Id: I15abfde5f72dbb3725a3f58621486afba6b64902
/frameworks/native/libs/vr/libvrflinger/display_service.h
3f82d31341f66d0c58e1ec3360ea5f528ffe0ea4 20-Apr-2017 Corey Tabaka <eieio@google.com> Remove unnecessary clients and rename files.

- Remove clients for obsolete services.
- Rename display protocol defs file to match purpose.
- Rename display manager client file. "impl" does not match naming
conventions used by DVR libraries.
- Remove video mesh surface interface. This will be replaced by more
general surface support in the unified O compositor.

Bug: 36401174
Test: Build; run cube sea.
Change-Id: Idb782623319329f6fa1b0aa45005d9fee3b9957d
/frameworks/native/libs/vr/libvrflinger/display_service.h
0057fddc71d1c3c3de8f9d0bd45a51bb293bfa3c 02-May-2017 Jiwen 'Steve' Cai <jwcai@google.com> Deprecate producer/consumer usage: Step 2

Clean up bufferhub_rpc, display_rpc and service side producer/consumer
usage reference.

Next (final) step is to remove all remaining client side reference to
producer/consumer usage and update dvr_xxx API.

This also fixes a minor typo in dvr_named_buffer-test

Bug: 37881101
Test: Build, flash, ran particles.apk and buffer_hub_queue-test
Change-Id: Ibae4376c1fd1ed964843d8b2ad2fb27204fe5e28
/frameworks/native/libs/vr/libvrflinger/display_service.h
eaa5522feac452703a0836310047d4b15702487d 06-Apr-2017 Hendrik Wagenaar <hendrikw@google.com> Convert the pose buffer into a more generic named buffer

* It's likely that we'll have more than one pose buffer
* It's cleaner to separate the vsync info into a separate buffer

Bug: 37001881
Bug: 37240552
Test: Added and manually ran TestNamedBuffersSetup
Change-Id: I76621d3cfa8c21c9d5d1e6e648854067673be9ab
/frameworks/native/libs/vr/libvrflinger/display_service.h
f0a7bd033941e26e380232a0515e903cf8e678e5 01-Apr-2017 Alex Vakulenko <avakulenko@google.com> pdx: Rework error reporting when transfering file and channel handles

There is a lot of confusion about reporting errors when passing file
and channel handles over PDX transport between client and service.

Methods like Message::PushFileHandle return an integer which means
both a file handle reference value (if positive) and a possible error
code (if negative). But file handles could contain negative values too
(when they are empty). This is used frequently when passing buffer
fences around (when a fence is not being used, its fd is set to -1).

This results in a special case of when PushFileHandle is called with
a file handle with value of -1, the return value is actually "-errno"
which becomes dependent on a global state (errno is not set by
PushFileHandle itself in case file handle value is negative) and results
in unpredicted behavior (sometimes errno is 0, sometimes its >0).

Cleaned this all up by using Status<T> everywhere we used an int to
pass value payload along with possible error code.

Now the semantics of the calls are more clear.

Bug: 36866492
Test: `m -j32` for sailfish-eng succeeds
Ran unit tests on device (pdx_tests, libpdx_uds_tests, bufferhub_tests,
buffer_hub_queue-test, buffer_hub_queue_producer-test), all pass
Ran CubeSea, NativeTreasureHunt and Ithaca on Sailfish with vrflinger
enabled, was able to use controller and screen rendered correctly.

Change-Id: I0f40c3f356fcba8bc217d5219a0ddf9685e57fd7
/frameworks/native/libs/vr/libvrflinger/display_service.h
b7c8a4bd8131ce18fb4ab4ee986c3b6b1ed27ad5 20-Mar-2017 Albert Chaulk <achaulk@google.com> Implement an API for vrwm to query if the current vr app is active

The API returns if the client_order 0 layer is visible or not. This
aids in 2D app detection

Bug: None
Test: Manual with permissionsgen & calculator

Change-Id: Id988e61a9f93885e93c28ed83ffaffd84f3bdf15
/frameworks/native/libs/vr/libvrflinger/display_service.h
050b2c83304bd16ec3a838da08b6ba6acf6a3af4 06-Mar-2017 Steven Thomas <steventhomas@google.com> Revert "Revert "Tie vr flinger to persistent vr mode""

This reverts commit 7480c060cb3466d97ec3125d61bbace153f534c8.

Transfer display control to vr flinger when persistent vr mode is
entered, rather than when vr mode is entered. This allows cardboard
apps, which will invoke vr mode but not persistent vr mode, to work as
in N.

This activates vr flinger at device boot for Daydream ready devices,
which fixes an issue where an app would attempt to create a surface
before vr flinger was running, which would hang indefinitely.

The VrManager listener for persistent vr mode is put in vr flinger
instead of surface flinger. This is cleaner since the vr interaction
with the rest of the device is now consolidated in vr flinger.

While testing I encountered a problem where vr flinger was given control
of the display but vsync was turned off, causing vr flinger's post
thread to hang. I changed the vr flinger logic to give control over
vsync and other display settings to the post thread, and took the
opportunity to further simplify and improve vr flinger's thread
interactions.

Bug: 35885165

Test: Manually confirmed that when persistent vr mode is not invoked we
get the N-based render implementation, and when persistent vr mode is
invoked we get vr flinger.

Change-Id: I3b5ad599cc0748e38b861c714c4cc3118f854acf
/frameworks/native/libs/vr/libvrflinger/display_service.h
10e68eb8aa4db8b6f8cfbf2c3754e2677d7bf848 15-Mar-2017 Hendrik Wagenaar <hendrikw@google.com> Add dvr_buffer apis

Test: None
Bug: None
Change-Id: I234d7ef4dabb4453cdbc67d3112adf2ffbbadaf4
/frameworks/native/libs/vr/libvrflinger/display_service.h
7480c060cb3466d97ec3125d61bbace153f534c8 21-Mar-2017 Jin Qian <jinqian@google.com> Revert "Tie vr flinger to persistent vr mode"

This reverts commit f43d13e4e35ae7d3cdafc4b97c819669d42cef78.

Change-Id: Ib67db8e51b7ea2dbbe6faccce36962bf5b44a6e2
/frameworks/native/libs/vr/libvrflinger/display_service.h
f43d13e4e35ae7d3cdafc4b97c819669d42cef78 06-Mar-2017 Steven Thomas <steventhomas@google.com> Tie vr flinger to persistent vr mode

Transfer display control to vr flinger when persistent vr mode is
entered, rather than when vr mode is entered. This allows cardboard
apps, which will invoke vr mode but not persistent vr mode, to work as
in N.

This activates vr flinger at device boot for Daydream ready devices,
which fixes an issue where an app would attempt to create a surface
before vr flinger was running, which would hang indefinitely.

The VrManager listener for persistent vr mode is put in vr flinger
instead of surface flinger. This is cleaner since the vr interaction
with the rest of the device is now consolidated in vr flinger.

While testing I encountered a problem where vr flinger was given control
of the display but vsync was turned off, causing vr flinger's post
thread to hang. I changed the vr flinger logic to give control over
vsync and other display settings to the post thread, and took the
opportunity to further simplify and improve vr flinger's thread
interactions.

Bug: 35885165

Test: Manually confirmed that when persistent vr mode is not invoked we
get the N-based render implementation, and when persistent vr mode is
invoked we get vr flinger.

Change-Id: Ieeb8dabc19e799e3179e52971f3b63f5a8f54b3b
/frameworks/native/libs/vr/libvrflinger/display_service.h
a3613612a1142c3134045f08c30a861ea43288ed 09-Mar-2017 Jiwen 'Steve' Cai <jwcai@google.com> Refactor VrFlinger to use BufferHubQueue

1/ Remove DisplayRPC::AllocateBuffer, as individual buffer allocation
is now handled by BufferHubQueue.
2/ Reimplement native_buffer_queue using bufferhubqueue.
3/ Hook up consumer queue in DisplaySurface.
4/ Remove epoll_event_dispatcher as its no longer being used.

Bug: 36033302
Test: Built and ran particles.apk
Change-Id: I38ee1c57195888ede935ebc50119bcb7e4ab4e36
/frameworks/native/libs/vr/libvrflinger/display_service.h
016e5e3ca751de7e86731349985d1eaf7c072515 22-Feb-2017 Stephen Kiazyk <skiazyk@google.com> Ensure display metrics on display service creation

This fixes a potential race condition where a VR app could request the
display metrics from the VR display service before it actually queries
them from the HWC.

Bug: None
Test: Compiled and ran Vr app.
Change-Id: Ie95b7f5a8ef2e286c7b2994ca94fd87214567e24
/frameworks/native/libs/vr/libvrflinger/display_service.h
3cfac28462910d3f976aebac54ac7301aca7e434 06-Feb-2017 Steven Thomas <steventhomas@google.com> Ignore callbacks from the non-active hardware composer

Ignore callbacks from the non-active hardware composer so we don't get
e.g. duplicate vsync callbacks, one from each composer.

Bug: None

Test: Manually confirmed with logs we're now ignoring callbacks on the
non-active composer.

Change-Id: I8b475d6283d86c64ff96b41e78528bce8c6ff1d3
/frameworks/native/libs/vr/libvrflinger/display_service.h
a8a92784bc5f6a50ce00311c6161fbcfc0898c5a 27-Jan-2017 Alex Vakulenko <avakulenko@google.com> Add libvrflinger for use in SurfaceFlinger

A separate CL uses this code from SurfaceFlinger.

Bug: None
Test: Manually ran modified SurfaceFlinger
Change-Id: I34588df1365588c0a0265e1e2325e3dd5516206a
/frameworks/native/libs/vr/libvrflinger/display_service.h