Commit Graph

365 Commits

Author SHA1 Message Date
Nader Jawad
dd1fcab19a Add logic to clean up resources more frequently
Added call to Skia's performDeferredCleanup method
to free resources that were not referenced within
the last 100 frames or 10 seconds whichever is
furthest away

Bug: 188450217
Test: manual
Change-Id: I3f37e1b5bd01330dbbc2da4a84b1259d56be2768
2021-06-15 10:14:04 -07:00
Jorim Jaggi
e4a52711e7 Ensure reportFrameMetrics not being called on deleted instance
Since onSurfaceStatsAvailable gets called on binder-thread, we
need to ensure that instance doesn't get released while
onSurfaceStatsAvailable is calling reportFrameMetrics.

Test: Boots
Bug: 188934435
Change-Id: Iafe582d6fe4087a3c4274ee39a2803abaa363fd2
2021-05-31 17:57:50 +02:00
rnlee
ce9762b57f Use TraceUtils.h from gui shared library.
Test: It makes
Bug: 183120308
Change-Id: I331262dd2da59817031f0c708f4c102041dcb5e0
2021-05-22 00:12:43 +00:00
Jorim Jaggi
b891cdf24a Use SwapBuffersCompleted as frame end time
...in case GPU completes really quickly.

Fixes: 181899835
Test: atest FrameMetricsListenerTest --iterations 50
Change-Id: I73b9380f92eb15f94ae4754746ee98c7fbc4e6c7
2021-05-17 23:24:03 +02:00
Huihong Luo
f410f8134f Merge "Fix leakage of ASurfaceTransactionCallback" into sc-dev 2021-05-14 03:33:53 +00:00
Bo Liu
4d0f1f1cce Ignore blocked-on-sf time for ADPF
Subtract out time spent blocked in dequeueBuffer. Also subtract out any
time UI spents waiting on render thread while render thread is blocked
dequeueBuffer, though this calculation is fairly crude.

Test: Checked bouncyball returns reasonable-ish numbers even when HWUI
      is ahead of surface flinger
Bug: 187556381
Change-Id: I368c446d93990ff8b7b645e30509405ba799c79c
2021-05-08 00:54:41 +00:00
Huihong Luo
e76f181372 Fix leakage of ASurfaceTransactionCallback
The callback needs to set to null when thread renderer is destroyed.

Bug: 187419942
Bug: 186869429
Test: blaze test --test_strategy=local --test_arg=--device_broker_type=LOCAL_ADB_SERVER //javatests/com/google/android/testing/elizabot/internal/sanity/subscriptionleak:SubscriptionLeakTest_generic_phone_google_31_x86
Change-Id: Ic80c58f102ee5f21830542030021828f6231cc37
2021-05-07 08:17:26 -07:00
Huihong Luo
054b8d3000 Webview overlay support
The basic idea is to create a child surface control from the root surface control passed from ViewRootImpl to the render thread.

Transactions are sent back to the java layer to get merged.

In case of offscreen layers, SurfaceControl must be disabled.

This new feature is disabled for Vulkan at the moment, a new CL will be used to enable the support.

Bug: 173671170
Test: manual, webview apks
Change-Id: I119405d13eca3c59fd3ec78e50dc7739f78411d4
2021-04-17 13:24:48 -07:00
John Reck
31164bc1ec Merge "Fix a logspam" into sc-dev 2021-04-14 13:46:27 +00:00
John Reck
6f97e15e3b Fix a logspam
On skiavk the flush to GPU happens sooner than it does on skiagl,
which was resulting in false-positive warning logs. Adjust the
condition to avoid this, so it should now only log if the GPU
fence time is significantly incorrect.

Fixes: 180488606
Test: doesn't log on skiavk
Change-Id: Ie6546b788663b5d863fb064f55245bead4eb0160
2021-04-13 12:09:12 -04:00
Jorim Jaggi
10f328c580 Change hwui jank detection to use deadline & gpu completion (1/2)
- Use GPU finish time as well as actual deadline to determine jank
rate.
- Use dynamic interval to adjust for 60/90hz switching
- Move frame metrics reporting into JankTracker to adjust the
deadline communicated to the app when in stuffing scenario.
- Adjust double-stuffing detection to be a bit more readable.

Test: GraphicsStatsValidationTest.java
Test: adb shell dumpsys gfxinfo
Test: FrameMetricsListenerTest
Test: Log output of FrameMetricsObserver
Bug: 169858044
Change-Id: I3a6b8ed163e2cf9cf2b67667110340ebe35f98a1
2021-04-13 15:18:27 +00:00
Greg Daniel
16d11c6d38 In CanvasContext check at start of frame if GrContext is abandoned.
On Vulkan part of the abandoned check also checks for device lost.
Following what we currently do in GL, we now crash if we are ever
in this state.

Test: local build
Bug: 183722403
Change-Id: I2a41005fd6892e32a8b23dacbc0170d5542fe072
2021-04-08 16:17:35 -04:00
Siarhei Vishniakou
adf5024a5d Send metrics notification just before frame advances
Currently, it is possible to notify frame metrics observers that
registered to receive present time about the same frame twice.

This is wasteful, but also requires the metrics listener to guard
against duplicates. See https://b.corp.google.com/issues/169866723#comment23

To avoid this issue, only notify about metrics with present time just
before the frame is advanced to the next position. This ensures that we
are always notifying about the last frame that's about to go away.

Bug: 169866723
Test: added a crash to LatencyTracker for the case where we are notified
about non-existent record. The record disappears once it's complete. So
the first call was completing the record, and the second call was
causing a crash. Now, the crash is gone with this patch.

Change-Id: Ia247b4a0010b8ecb016ac66e44e211ec4f40bf8f
2021-03-11 21:59:15 +00:00
Siarhei Vishniakou
f0cf18d3ed Pass actual present time to ViewRootImpl
To measure end-to-end touch latency, we need to report the actual
present time to ViewRootImpl. ViewRootImpl, in turn, will report this
information to InputDispatcher. Finally, InputDispatcher will combine
all known information for a specific input event, and will report this
data to westworld.

In another patch, we will add a new call, 'reportLatencyInfo', to
InputPublisher. This call will allow the app to send this latency data
to InputDispatcher.

Bug: 169866723
Test: printed the input event present times inside ViewRootImpl
Change-Id: Ibd3a2cfeb1a340eb15cd2165071df1f8589634af
2021-03-05 21:42:32 +00:00
Siarhei Vishniakou
4bcbffd584 Add presentTime to FrameInfo
Present time is available to apps, but is not currently stored inside
FrameInfo. In this CL, we add a location for storing the present time inside
FrameInfo.

Currently, the metrics reporter is triggered after the buffer is sent to
SurfaceFlinger. That means, metrics for anything that happens after gpu
draw completes are currently not available.

In a future CL, we will populate the 'presentTime' field.

In a future CL, we will register a metrics observer inside ViewRootImpl
in order to send this data to InputDispatcher. This will enable
end-to-end touch latency metrics collection.

Bug: 169866723
Test: printed present time inside FrameTimeline.cpp (surfaceflinger
side) and compared to the values printed inside a metrics observer
registered in ViewRootImpl (not done in this CL)
Test: atest ViewFrameInfoTest

Change-Id: I7d0f8c5d7b5a2572abdc4e107123e8938a36f582
2021-02-18 22:07:09 +00:00
Jorim Jaggi
71db8892ac Add GPU completion to FrameMetrics (1/3)
- Add SurfaceStatsCallback to TransactionCompletedListener
- Register a callback in RenderProxy to be called when we have
surface stats from SF via the BLAST callback.
- Instead of finishing a frame for frame metrics reporting
immediately, wait until BLAST callback fires, note GPU completion
time and finish frame.
- Expose GPU_COMPLETION in FrameMetrics
- Modify TOTAL_DURATION to also include GPU_COMPLETION

Test: FrameMetricsListenerTest
Fixes: 171046219
Change-Id: I16fa1d80cfc4e7a5527c18fec7e885409f17ee4d
2021-02-17 14:55:22 +01:00
Huihong Luo
5fdf7b8d26 Add SurfaceControl to hwui
add a method, setSurfaceControl, for java layer to pass surface control to the render thread

Bug: 173671170
Test: call setSurfaceControl method in ViewRootImpl.java
Change-Id: I886a79c377938f19cf38b9058f2bec64e1439000
2021-02-16 17:38:12 +01:00
Ady Abraham
7bb70faa04 Remove render ahead from hwui
As HWUI uses vsync id to send buffers to SF, SF applies the right
amount of render ahead by latching the buffers at the configured time.

Test: launch an app and observe systrace
Bug: 178148035
Change-Id: Ifd3e1a2971aad0a085cb35d33e950194046aa634
2021-02-08 18:13:45 +00:00
John Reck
1aee20138c Merge "Fix render_ahead properties" into sc-dev 2021-02-04 18:29:11 +00:00
John Reck
f516e3a36e Fix render_ahead properties
0 and -1 both meant default when 0 should mean
0 and -1 should mean default

Test: manual
Fixes: 179290765
Change-Id: Ia9aa5e3d83757282bfff776e083d6b3d7d29e9c0
2021-02-03 15:30:05 -08:00
Siarhei Vishniakou
d11f38f6c5 Send input event id to SurfaceFlinger
The application receives input events and produces graphic buffers in
response. We are interested in measuring the total time that the input
event takes to process, from the moment it's received on the device, to
the moment that the image is displayed on the screen.

To do this, we need to understand which input event produced a specific
buffer. In this CL, we are sending the input event id from FrameInfo to
SurfaceFlinger. This event id will later be used to identify a specific
frame, and provide the frame timing information to inputflinger.

Inputflinger will be able to use this information to reconstruct the
complete event timeline, and record metrics on the duration of each
input / graphics processing stage. This will allow us to optimize
end-to-end touch latency.

In the current CL, we are using 'NewestInputEvent' as the inputEventId.
That's not quite correct. Today, this field contains the timestamp of
the input event. Therefore, we will simply pass the truncated
timestamp instead of proper input event id. We will fix this in a
separate CL by providing input event id to FrameInfo.

Design doc: https://docs.google.com/document/d/1G3bLaZYSmbe6AKcL-6ZChvrw_B_LXEz29Z6Ed9QoYXY/edit#
Bug: 169866723
Test: printed input event id at the site of SurfaceFrame creation in
FrameTimeline.cpp

Change-Id: Ia90337bb2f000e9c93a4db04d9dd6ea9ea153520
2021-01-29 18:41:08 +00:00
Vishnu Nair
70a8f0ea98 HWUI: Finish frame callbacks before framecomplete callbacks
If returning early from a draw, there is a chance that the frame
complete callbacks can execute before the frame callbacks. To fix
this, explicitly wait on frame callbacks to complete.

Test: Enable blast and test split screen resize
Change-Id: Id0eabd4dacdccbf1ce774efaad51abae7c57d5ea
2020-10-15 11:50:30 -07:00
Ady Abraham
dfb13985af pass frame deadline to Choreographer
Pass the frame deadline calculated by SF to Choreographer so
hwui would be able to improve its stats by knowing if a frame is
likely to be late.

Bug: 169858174
Test: manual
Change-Id: Ib9fd93638b54f08d8dc72fa6b023e2dd7c276dc7
2020-10-09 11:17:32 -07:00
TreeHugger Robot
b5cb0b58b7 Merge "Fix override setBufferCount" 2020-09-21 23:03:38 +00:00
John Reck
fbe14bbbd3 Fix override setBufferCount
The logic in setBufferCount was still assuming it needed
to inject the extra buffers, however that injection was
already happening in the min_undequeued query. So it was
increasing buffercount by 2x the extraCount, or concretely
5 buffers when it should have been 4 on >75hz devices

Bug: 168928692
Test: Boot coral, verify 4 buffers instead of 5
Change-Id: I0908228a6791d90544fbf4cb21170931bd31a9db
2020-09-21 14:37:41 -07:00
Steven Thomas
6fabb5aa17 Shared timeline plumbing
Add plumbing to get shared timeline data from Surface Flinger to HWUI
and back.

Bug: 162890382
Bug: 162888881
Bug: 162890407

Test: manual using ALOG messages in SF
Change-Id: I85c5eb56d2fa933889518854e7b79b1e65e29af3
2020-09-16 22:58:39 -07:00
John Reck
b36bfddb1e Wire-up colorMode="hdr"
Fow now it uses a fixed white point of 150nits
TBD if this is disabled or adjusted

Test: Demo app
Change-Id: Iac13597b3d7633fdef3feaf7ec1da0c27c87904c
2020-07-30 08:54:03 -07:00
John Reck
8ddbc59d55 Avoid excessive KGSL maps
Hook MIN_UNDEQUEUED_BUFFERS if possible to avoid thrashing kgsl
maps when render_ahead is being used

Bug: 143555869
Test: verified kgsl maps only happened once per buffer
Change-Id: I985fae0a9a7635be3a1cf6177186e5541a1169df
2020-05-07 16:47:10 -07:00
chaviw
5fc80e7b32 Send drawFinish callback even if did not draw
There are cases where ViewRootImpl requests to draw, but there was
nothing new to draw. In that case, the callback will never be invoked
and ViewRootImpl will wait forever.

This change will invoke the callback even if there is nothing to draw.
It will use the last frameNumber since nothing new has drawn

Test: Request draw with nothing new. Callback is invoked
Fixes: 155429223
Change-Id: I7c9ed7fd63a451b17133a11ffbcf8fb64be558e5
2020-04-30 14:38:52 -07:00
Alec Mouri
026106f6d6 [HWUI] Add null check for CanvasContext
If ReliableSurface is forced to acquire a fallback buffer then the
Surface may be abandoned. When getting frame timestamps we need to check
that the Surface still exists.

Bug: 152262035
Test: builds, boots
Test: dumpsys gfxinfo
Change-Id: Ifdb198ebf74cc9dc681c4ab51c4901176a7f5fc9
2020-03-26 18:09:53 -07:00
Alec Mouri
43fe6fcde5 [HWUI] Remove references to gui/Surface.
ANativeWindow usage now has enough feature parity so that we can use
that instead.

Bug: 137012798
Test: builds
Test: Scroll through settings
Change-Id: I0054315058b28bcb5e779a6f71a3cfb164625a5f
2020-02-14 15:24:16 -08:00
Alec Mouri
c9d5f3d952 [ANativeWindow] Rename allocateBuffers to tryAllocateBuffers
Renaming was done in response to API feedback.

Bug: 148962594
Test: builds
Change-Id: I05b3e99800d967dda243b6e7af48f1b645909bdd
2020-02-13 13:58:50 -08:00
Derek Sollenberger
3109b4cc47 Merge "Ensure SkiaPipeline always has a valid colorspace." 2020-02-06 19:47:24 +00:00
Alec Mouri
ff07c8fd76 [HWUI] use native_window timestamp apis
These aren't finalized as stable yet until we sort out some BufferQueue
challenges.

Bug: 137012798
Test: builds
Change-Id: Icd5eb02afc4cf16a2be485e6710f71818b300b9d
2020-02-06 08:09:30 -08:00
Derek Sollenberger
1863d94e9a Ensure SkiaPipeline always has a valid colorspace.
Previously we didn't assign a colorspace to the pipeline until it
was provided a surface to render into.  This resulted in undefined
behavior if the application attempted to render an offscreen layer
before the OS provided the main window with its surface. Now instead
of deferring setting whether or not the application is wide gamut we
do initialize it to a default setting when the pipeline is created.

Bug: 148042673
Test: apct/device_boot_health_check_extra_postsubmit
Change-Id: I84d743511e949ac977486470bb14eec936de7f88
2020-02-06 07:41:50 -05:00
John Reck
869cb2ad7e Merge "Adjust present time calculation" 2020-02-05 20:39:54 +00:00
John Reck
56cffe5b6a Adjust present time calculation
Adjust the target present time when using
render_ahead to better fit in the gaps between
vsync pulses. This prevents small clock
drifts from causing jank.

Bug: 143540628
Test: manual, looked at systrace
Change-Id: I26ae6ebf16a3dea48dfd8e1c420d9e5e43e42bcb
2020-02-03 16:47:12 -08:00
Alec Mouri
80c7ef17db [HWUI] Use ANativeWindow_getNextFrameId api.
This is part of the work to move away from gui/Surface and onto
ANativeWindow in HWUI.

Bug: 137012798
Test: builds
Change-Id: I5862d7833b583b8295d1677e725ed58d97808b27
2020-02-03 10:25:24 -08:00
Alec Mouri
c2a6537fb9 [HWUI] Hook up ANativeWindow_allocateBuffers
Bug: 137012798
Test: builds
Change-Id: Iefe7b73470cb6229fc72d1a1aa33eceb827f527c
2020-01-30 18:28:48 -08:00
Alec Mouri
f023a323de [HWUI] Use ANativeWindow inteception methods in ReliableSurface
Test: boots
Test: manually test with opening and scrolling through settings app
Change-Id: I8d7a44d3ead0b2350318e1514153e256f97ccca5
2020-01-30 18:26:41 -08:00
Stan Iliev
e0fae2356b Add memory tracing in HWUI
Add ATRACE memory counters to track memory usage at the end
of each frame in HWUI.
There are 3 catagories: CPU, GPU and Texture memory.
There are 3 more counters for memory that can be purged.
This CL deletes GpuMemoryTracker class, which implemented
similar function for Android O HWUI renderer.

Test: Collected systrace with gmail and setting.
Test: memory tracing adds ~0.1ms per frame when ATRACE is enabled
Bug: 146580770
Change-Id: Icbcc0478bc426dff578e83726fe7c95df171ed93
2020-01-10 16:14:39 +00:00
John Reck
cd18c2271d Fix for Surface#lockHardwareCanvas lockups
By avoiding setting a dequeue buffer timeout we avoid
hitting a different path in BufferQueue that prevents
async behavior from happening. This restores P's
behavior in this path.

Bug: 143860379
Test: repro app in bug
Change-Id: Iffbd9f9e6689a40876ff3aa74c10020e3f09fc6a
2019-11-21 15:16:08 -08:00
Stan Iliev
10689992cf Fix an issue with GPU stats not enabled
Invoke Surface::enableFrameTimestamps after eglDestroySurface.
eglDestroySurface internally disables time stats. Order is
important, when CanvasContext::setSurface is invoked with
a surface, that is already current (which happens all the time).

Test: ran UiBench microbenchmark tests
Change-Id: I3d023c3a87da6329c556426d553c744e541b9dff
2019-11-13 11:48:04 -05:00
Alec Mouri
05955610a0 Merge "[HWUI] Get DeviceInfo through stable ABI" 2019-11-07 17:15:47 +00:00
Nick Desaulniers
b451d87468 [frameworks][base][hwui] re-fix -Wimplicit-int-float-conversion
A new instance snuck in since I haven't completed the platform toolchain
upgrade yet. There was imprecision in this call; accept it by making the
implicit cast explicit.

Bug: 139945549
Test: mm
Change-Id: Id704d9741b480eba4cf3955e70119d935776faf6
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2019-11-04 17:18:51 -08:00
John Reck
4145919ef9 Fix wrong surfaceRequiresRedraw check
We only need to redraw if the size /changed/ not
if it was the same. Also fix damageId to not use
frameNumber as repeated redraws of the same frame
would toggle.

Bug: 143711430
Test: systrace
Change-Id: I8ac4629c9ff4fd51de33d1be7aa46ccc995ba342
2019-10-31 15:04:58 -07:00
TreeHugger Robot
b051671aa3 Merge "[HWUI] Use ANativeWindow_get{Height, Width}" 2019-10-29 09:39:18 +00:00
Alec Mouri
da819e47f1 [HWUI] Use ANativeWindow_get{Height, Width}
gui/Surface will eventually be removed since HWUI needs to depend on a
stable ABI, so use the NDK methods for querying width and height that
operates on ANativeWindow instead.

Bug: 137012798
Test: builds
Change-Id: I1309e31992190e7b44c6ea83f962f372b6b0afcf
2019-10-25 16:18:16 -07:00
Alec Mouri
22d753f74d [HWUI] Get DeviceInfo through stable ABI
This also removes the dependency on ui/DeviceInfo other than in test
code.

Bug: 136263392
Bug: 136263238
Test: builds, boots
Change-Id: I6a4687e981359f0e6beb83be8a5501ed7fd16f15
2019-10-25 13:30:42 -07:00
John Reck
83161dcd6a Delete VectorDrawableAtlas
Poking around in a few apps it doesn't appear that
the VectorDrawableAtlas is achieving sufficient
utilization to justify its existence. The potential for
draw call merging doesn't seem warranted for the
RAM cost of the atlas.

Bug: 137853925
Test: builds
Change-Id: Id2419bc6dccb6316636d50c568f8fac75a2d563f
2019-10-04 14:49:20 -07:00