Commit graph

79008 commits

Author SHA1 Message Date
Ady Abraham
b74fe1dc23 Merge changes from topic "sf_157096772" into rvc-dev
* changes:
  SurfaceFlinger: clear LayerHistory on first touch
  Revert "SurfaceFlinger: more aggressive infrequent layer detection"
  Revert "SurfaceFlinger: tune MAX_FREQUENT_LAYER_PERIOD_NS for inactive layers"
  Revert "SurfaceFlinger: tune infrequent detection logic more"
2020-05-29 03:45:06 +00:00
TreeHugger Robot
0b257105a2 Merge "Process focus events first" into rvc-dev 2020-05-28 22:28:05 +00:00
Siarhei Vishniakou
de1bc4a4e3 Process focus events first
While refactoring ANR logic, we discovered that an existing Q behaviour
was broken by the focus refactoring. The behaviour aims to prevent keys
from being sent to incorrect windows.

The desired behaviour is as follows: if there are any unfinished events,
then do not process key events (keep them pending), which would allow
these key events to go to a new window, if one becomes focused. The
intent is that if the user hits "Alt+Tab" to switch to another window,
and starts typing right away, we want to make sure that we have
processed the focus event for the new window prior to determining where
to send the new key events after Alt+Tab.

The behaviour is broken today because we put the focus events at the
back of the queue. So even if we process the focus event first, it would
still go to the app after the key event, which would mean that the new
window may receive it, but would drop it because that window does not
yet have focus (since we haven't sent the focused event to it).

The proposed solution is to always put the focus events in the front of
the queue. But, we still need to preserve the relative order of focus
events. To account for that, we put a new focus event always at the
front of the queue, but behind any other focus events that may be there.

Bug: 143459140
Test: added in ANR CL because this behaviour is updated there.
Change-Id: I95256bd3f57988d1990cf1f21267c8f405892e8e
Merged-In: I95256bd3f57988d1990cf1f21267c8f405892e8e
2020-05-28 14:05:17 -07:00
Ady Abraham
a6b676e33a SurfaceFlinger: clear LayerHistory on first touch
- Restructure the code in RefreshRateConfigs to be able to clear
   LayerHistory frames on the first touch event. Without this change we
   clear the history on every frame as long as the touch timer hasn't
   expired.
 - Add log prints for debugging

Test: Play 24fps video in YouTube PIP mode and rotate the device - no jank
Test: Chrome playing video - no refresh rate switching
Test: Hide/Show keyboard when inputting text
Test: Running Hay Day and observing refresh rate
Bug: 157096772
Change-Id: I7cabecd6ea27ec335e773aa22bb111fa8ec89195
2020-05-28 18:48:29 +00:00
Ady Abraham
dfb63ba78b Revert "SurfaceFlinger: more aggressive infrequent layer detection"
This reverts commit 1adbb72759.

Reason for revert: Causing regression with b/157096772

Change-Id: Ib2009f7a4ecbd268ea69304853a91bd22674ec1e
Test: Play 24fps video in YouTube PIP mode and rotate the device - no jank
Test: Chrome playing video - no refresh rate switching
Test: Hide/Show keyboard when inputting text
Test: Running Hay Day and observing refresh rate
Bug: 157096772
Bug: 155062712
Bug: 156654519
2020-05-28 18:48:22 +00:00
Ady Abraham
f5bc779caa Revert "SurfaceFlinger: tune MAX_FREQUENT_LAYER_PERIOD_NS for inactive layers"
This reverts commit eeb74561b6.

Reason for revert: Causing regression with b/157096772

Change-Id: I031219588cedf5cfcb75255430f707428ed59f72
Test: Play 24fps video in YouTube PIP mode and rotate the device - no jank
Test: Chrome playing video - no refresh rate switching
Test: Hide/Show keyboard when inputting text
Test: Running Hay Day and observing refresh rate
Bug: 157096772
Bug: 157110371
2020-05-28 18:42:59 +00:00
Ady Abraham
af6d8a4142 Revert "SurfaceFlinger: tune infrequent detection logic more"
This reverts commit 39db2c9b07.

Reason for revert: Causing regression with b/157096772

Change-Id: I058d6f8efa637cb36371276761281f51b7aa3dd3
Test: Play 24fps video in YouTube PIP mode and rotate the device - no jank
Test: Chrome playing video - no refresh rate switching
Test: Hide/Show keyboard when inputting text
Test: Running Hay Day and observing refresh rate
Bug: 157096772
2020-05-28 18:41:02 +00:00
TreeHugger Robot
69c7197c3e Merge "Generate ACTION_CANCEL event when screen turned off by proximity sensor." into rvc-dev 2020-05-28 18:35:08 +00:00
TreeHugger Robot
6de39e03fb Merge "gralloc4: Support RAW type in PlaneLayoutComponentType" into rvc-dev 2020-05-28 02:13:29 +00:00
Chavi Weingarten
a38a3e145a Merge "Hold mMutex lock and check abandoned when accessing mLayer" into rvc-dev 2020-05-28 00:16:11 +00:00
TreeHugger Robot
ac17aa0a0f Merge "Plumb client target property." into rvc-dev 2020-05-27 23:28:52 +00:00
chaviw
1a4dba4b2b Hold mMutex lock and check abandoned when accessing mLayer
The Layer lifecycle is tied to BufferLayerConsumer so when the Layer is
removed, the BufferLayerConsumer is abandoned. However, abandoned
doesn't necessarily mean it was cleaned up yet. Therefore, we need to
check whether the BufferLayerConsumer was abandoned before accessing the
raw pointer mLayer. If the BufferLayerConsumer was not abandoned, then
mLayer will be valid.

Test: Builds and runs. Hard to reproduce race condition
Fixes: 157535966
Fixes: 155679049
Change-Id: I8b309c9e1fe57746bceabab1deda56248087b189
2020-05-27 15:16:15 -07:00
Alec Mouri
a9e0d8a9e3 Merge "Lock display refresh rate when primary range is a single rate." into rvc-dev 2020-05-27 21:55:30 +00:00
Yichi Chen
706933754b gralloc4: Support RAW type in PlaneLayoutComponentType
The patch creates RAW type in PlaneLayoutComponentType to make list
complete.

Bug: b/157534008
Test: VtsHalGraphicsMapperV4_0TargetTest
Change-Id: I871f90756eafb848cf7489b9710f4df47f8f8ec2
2020-05-27 16:24:43 +08:00
Marin Shalamanov
c7f9e4eea2 [SF] Make sure destination clip is contained in display bounds
When we render on a framebuffer with smaller size than the
currently active mode the destination clip can get outside
of the display bounds. For examlple, if the currently
active display mode is 4K, but we render on a 1080p framebuffer,
dest clip = 4k, but display bounds =1080p. As a result of that
only the top left quarter of the image is visible on screen.

Bug: 153991408
Test: manually make sure the image is properly displayed on sreen
     1. boot device
     2. turn off HWC with adb shell service call SurfaceFlinger 1008 i32 1
     3. turn on HWC with adb shell service call SurfaceFlinger 1008 i32 1
     4. start a youtube video and repeat 2 and 3.
Test: take a screenshot and check it's correctly displayed
Test: atest libsurfaceflinger_unittest librenderengine_test
Merged-In: Ia7b6ebd311c1b751c1966a34a9294b9b85a2aa0b
Change-Id: Ia7b6ebd311c1b751c1966a34a9294b9b85a2aa0b
(cherry picked from commit fcfe1360a4)
2020-05-25 11:37:56 +00:00
Jesse Hall
68904ad94c Merge "libvulkan: support vkGIPA self-query" into rvc-dev 2020-05-22 21:03:03 +00:00
Ady Abraham
ff9926fcf2 Merge "SurfaceFlinger: tree vote for FrameRateCompatibility::ExactOrMultiple" into rvc-dev 2020-05-22 06:43:19 +00:00
Ady Abraham
507056a4f4 Merge "SurfaceFlinger: tune infrequent detection logic more" into rvc-dev 2020-05-22 02:15:10 +00:00
Ady Abraham
fd201b3cc5 Merge "SurfaceFlinger: tune MAX_FREQUENT_LAYER_PERIOD_NS for inactive layers" into rvc-dev 2020-05-22 02:14:56 +00:00
Ady Abraham
36725c77ca Merge "SurfaceFlinger: frame rate heuristic during config change" into rvc-dev 2020-05-22 02:14:41 +00:00
Ady Abraham
414e8b5cb7 SurfaceFlinger: tree vote for FrameRateCompatibility::ExactOrMultiple
Layers that voted with FrameRateCompatibility::ExactOrMultiple
will still allow touch boost as those layers are typically not
interactive and therefore touch is probably meant for a different
layer. For the same reasoning, we should continue to heuristically
calculate frame rate for layers in the same tree.

Bug: 157254751
Test: run Swappy with statistics overlay and observe refresh rate
Test: run YouTube, play a video, scrolling the recommended videos and observe refresh rate
Change-Id: I9311512a663eba61dfcae6277a52c077e135a244
2020-05-22 00:49:17 +00:00
Jesse Hall
7559c76d12 libvulkan: support vkGIPA self-query
vkGetInstanceProcAddr(nullptr, ...) is valid and is effectively a
globally dispatched function, so it's consistent to support querying
vkGetInstanceProcAddr from itself without an instance.

This is required in Vulkan 1.2 and is supported for all Vulkan versions
by the loader on other platforms. To maximize app compatibility and
minimize surprises, this makes it work on Android also, even for pre-1.2
versions where the result is undefined by the spec.

Bug: 157173922
Test: dEQP-VK.api.version_check.entry_points with
      https://gerrit.khronos.org/#/c/5490/ applied and modified to
      check even on pre-1.2 implementations.
Change-Id: I820dd1239df54a415b7ff5db47cf2c2b349f6155
2020-05-21 16:28:48 -07:00
Ady Abraham
39db2c9b07 SurfaceFlinger: tune infrequent detection logic more
A layer will be considered frequent unless proven otherwise, in order
to make sure animations will change the refresh rate as soon as possible.
In addition, if a layer is classified infrequent, then we will keep it
infrequent until we get a burst of frames. These two policies combined
allow us to differentiate between an animating layer and a layer that
usually doesn't animate.

Bug: 157096772
Test: Play 24fps video in YouTube PIP mode and rotate the device - no jank
Test: Chrome playing video - no refresh rate switching
Test: Cursor blinking on Messages - switch to lowest refresh rate quickly
Change-Id: I3629b6e4786cd43919f51465e347f2abb52234d9
2020-05-21 16:16:56 -07:00
Ady Abraham
eeb74561b6 SurfaceFlinger: tune MAX_FREQUENT_LAYER_PERIOD_NS for inactive layers
Tune the threshold for detecting inactive layers to treat 24fps
videos without presentation timestamps as frequent.

Bug: 157110371
Test: Chrome playing video and observe systrace
Change-Id: I6908761ef2af7e40cd40eda6e1e66c8e1a01393f
2020-05-21 15:45:07 -07:00
Ady Abraham
32efd54dfa SurfaceFlinger: frame rate heuristic during config change
Some devices might takes a few frames to change the refresh rate.
Calculating the frame rate should ignore frames sent while changing
the refresh rate as those might result in an inaccurate frame rate
due to frame misses.

Bug: 156530990
Test: Running Hay Day and observing refresh rate.
Change-Id: I99f364cd1816c3ce2ba3c3145331eb618dcaea71
2020-05-21 15:41:49 -07:00
Alec Mouri
11232a26ad Lock display refresh rate when primary range is a single rate.
When DMS enforces a fixed refresh rate to hide user-visible flickering,
we must respect that refresh rate to avoid unnecessary switches during
scenarios such as idle and touch boost.

We must still respect app votes when they explicitly provide a frame
rate.

Bug: 156315203
Test: Exoplayer
Test: Modified version of SetFrameRateTest to simulate 60hz video
Test: libsurfaceflinger_unittest
Change-Id: I5fe974ddaff30e2f02e381cb63e0a6418834fdb5
2020-05-21 11:36:01 -07:00
TreeHugger Robot
76ad0655bb Merge "log when waiting on a servicemanager" into rvc-dev 2020-05-20 19:14:41 +00:00
Steven Moreland
fb10b6b588 log when waiting on a servicemanager
Since vndservicemanager is no longer installed by default, this gets hit
on those devices.

Fixes: 156571068
Test: TH
Change-Id: I31af865326e9a69042e5c53b63637b95d6de9ad1
(cherry picked from commit 39a572183a)
Merged-In: I31af865326e9a69042e5c53b63637b95d6de9ad1
2020-05-20 17:58:05 +00:00
Jooyung Han
513a77cffd Merge "setDefaultImpl aborts on a second call" into rvc-dev 2020-05-19 23:00:08 +00:00
Jooyung Han
01097e2410 setDefaultImpl aborts on a second call
The actual problem is that default implementation is set globally.
setDefaultImpl might not work as expected when it is called twice with
different instances.

Because we don't have a proper solution for the problem, we prevent
calling setDefaultImpl() twice by aborting.

Exempt-From-Owner-Approval: approved

Bug: 140139809
Test: ./runtests.sh (in /system/tools/aidl)
Merged-In: I659d3eaad3a45dcba608fa79a08f083f84bc4d58
Change-Id: I659d3eaad3a45dcba608fa79a08f083f84bc4d58
(cherry picked from commit 81087399e9)
2020-05-19 22:59:49 +00:00
Chris Ye
796fbbbcbb Generate ACTION_CANCEL event when screen turned off by proximity sensor.
When using PROXIMITY_SCREEN_OFF_WAKE_LOCK and screen was turned off by proximity sensor,
input service should generate ACTION_CANCEL, same as display turned off by pressing power button.

Bug: 154074380
Test: atest libgui_test
Change-Id: I72a10c98adad4a236dbd445cefe5f37c4ec3fd81
Merged-In: I72a10c98adad4a236dbd445cefe5f37c4ec3fd81
2020-05-19 11:36:14 -07:00
Michael Hoisie
c30ebd0188 Merge "Remove unused dependencies in SurfaceFlinger" into rvc-dev 2020-05-19 18:09:55 +00:00
Steven Thomas
98b789db15 Merge "With content detection off, prefer default frame rate" into rvc-dev 2020-05-19 17:47:14 +00:00
Steven Moreland
63da46c3ec Merge "libbinder: do not destruct SM global" into rvc-dev 2020-05-19 17:43:53 +00:00
Michael Hoisie
0b793843b3 Remove unused dependencies in SurfaceFlinger
* Remove libsync from libcompositionengine
* Remove libvr_manager from libsurfaceflinger
* Remove libdl from libsurfaceflinger

Test: m -j
Bug: 156932275
Change-Id: Id4b267c2aa2f902484c683219b4794d934b03901
2020-05-19 12:01:08 -04:00
Steven Thomas
debafed2c7 With content detection off, prefer default frame rate
When content detection is off, or when we have no layer information to
make a decision, prefer the default frame rate.

Bug: 154648391

Test: - Modified a Pixel 4 to turn off content detection, idle, touch,
        and power boost. Confirmed that, without this CL, we have bad
        behavior where calls to setFrameRate() persist after the layer
        goes away, and that this CL fixes that behavior.

- Modified and enhanced the "no layers" unit test in
  RefreshRateConfigsTest.cpp.

Change-Id: I2fd0d64a6ad369580cbb2ebf91cbbed7c31e0281
2020-05-18 18:56:19 -07:00
TreeHugger Robot
efde450428 Merge "gui/math/gralloc: Set min_sdk_version" into rvc-dev 2020-05-19 00:02:04 +00:00
TreeHugger Robot
b79738ea70 Merge "Remove hot-path logging" into rvc-dev 2020-05-18 22:10:38 +00:00
Ady Abraham
51a1625ac0 Merge "SurfaceFlinger: more aggressive infrequent layer detection" into rvc-dev 2020-05-18 21:05:01 +00:00
Ady Abraham
1adbb72759 SurfaceFlinger: more aggressive infrequent layer detection
Change the algorithm that chooses the refresh rate to treat layers as
infrequent unless proven otherwise. This change helps with multiple
switches during scenarios of blinking cursor where the detection of
infrequent layer is too long. The down side on this change is that
animations will be considered infrequent as well for the first few frames.
However the touch boost is a good mitigation of this.

Test: Typing in Messages and observe refresh rate
Test: Settings->About->up time and observe refresh rate
Bug: 155062712
Bug: 156654519
Change-Id: I317c69bd063df5d70f2d5705163cf61c1c9b1fff
2020-05-18 17:49:01 +00:00
Steven Moreland
26476f3e0b libbinder: do not destruct SM global
Let linux clean it up, since this may be accessed by some threads after
the main thread is destructed.

Bug: 154507808 # longterm
Bug: 156785633

Test: w/ repro which calls defaultServiceManager off main thread
Change-Id: Ic109f4bdca3893e6b0b192ac27f3ff03ada6f9e2
(cherry picked from commit 1698ffd088)
Merged-In: Ic109f4bdca3893e6b0b192ac27f3ff03ada6f9e2
2020-05-18 17:36:56 +00:00
Michael Hoisie
9b5bf0f42d Merge "Add null check for fgets in BufferQueueCore" into rvc-dev 2020-05-16 19:59:25 +00:00
TreeHugger Robot
39bf04a268 Merge "Revert "Revert "Revert "Make libbinder not available to media.sw..."" into rvc-dev 2020-05-16 18:03:50 +00:00
Adam Wright
4d360c65f5 Revert "Revert "Revert "Make libbinder not available to media.sw..."
Revert submission 11485868-reland-libbinder

Testing potential culprit for b/156778943 ("pthread_mutex_destroy called on a destroyed mutex" inside libstagefright).

Reason for revert: broken above test
Exempt-From-Owner-Approval: revert due to test breakage.

Reverted Changes:
I045836e10:Use NO_IMEMORY version of libstagefright_foundatio...
I23f41fece:Revert "Revert "Make libbinder not available to me...
bug: 156778943

Change-Id: Idfea55e47cd80dc80c58bfef20e7e274f944dcaf
2020-05-16 18:03:34 +00:00
TreeHugger Robot
692c65bfb6 Merge "Pass BTN_GEAR_DOWN and BTN_GEAR_UP to apps" into rvc-dev 2020-05-16 01:13:57 +00:00
Chong Zhang
12a5e88df9 Merge "Revert "Revert "Make libbinder not available to media.swcodec apex""" into rvc-dev 2020-05-16 00:02:30 +00:00
TreeHugger Robot
b209e7b56b Merge "SF: Enforce thread safety for SurfaceFlinger class" into rvc-dev 2020-05-15 23:38:34 +00:00
TreeHugger Robot
418a9e4235 Merge "Reduce the usage of goto statements in dispatcher" into rvc-dev 2020-05-15 23:16:34 +00:00
TreeHugger Robot
289e402dac Merge "[SF] Rename variables to match style" into rvc-dev 2020-05-15 22:28:40 +00:00
Dominik Laskowski
a19f4b6238 SF: Enforce thread safety for SurfaceFlinger class
Add thread annotations to display state and accessors. Add macros and
RAII helpers as escape hatches that are stricter and more meaningful
than NO_THREAD_SAFETY_ANALYSIS, and emit error on use of the latter.

Bug: 123715322
Test: Build
Change-Id: Ibada81998d70c940c7406ef292b2d487fb02189d
Merged-In: Ibada81998d70c940c7406ef292b2d487fb02189d
2020-05-15 20:42:49 +00:00