summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/CanvasContext.cpp
AgeCommit message (Collapse)Author
2022-03-15Merge SP2A.220305.013Haamed Gheibi
Bug: 220074017 Change-Id: Idfdd94e902f656ac65a2a75dfdd199f6f85ba472
2021-08-06CanvasContext::draw: flushAndSubmit when not drawingLeon Scroggins III
Bug: 195081399 Test: manual + dumpsys gfxinfo CanvasContext::draw has some conditions under which it will not draw. We still need to flushAndSubmit to free scratch memory if there were texture uploads this frame. Change-Id: I60d230cd36bed310a3155e4f1ca647c99c13c4cd
2021-07-11Merge "Properly protect mFrameMetricsReporter" into sc-devTreeHugger Robot
2021-07-09Properly protect mFrameMetricsReporterSiarhei Vishniakou
This field actually requires a special lock, mFrameMetricsReporterMutex. But there isn't a GUARDED_BY annotation for it. And even if there was, the compiler feature of -Wthread-safety was not active in this code, so this error would not have been caught. To fix this, enable the compiler annotation and add GUARDED_BY annotation to mFrameMetricsReporter. And finally, use this lock to properly protect this field. Bug: 192330836 Test: atest hwui_unit_tests Change-Id: I76950bfa01bbd7ccdc54c4e8c114430b5aeddf1a
2021-07-07Reduce number of weakrefs per frameJohn Reck
Disable end-to-end input latency metric to reduce the number of JNI WeakGlobalRef acquires per-frame. Bug: 189738006 Test: Observe trace section no longer appears in calculator Change-Id: I062dad8e7cec93cca5599e51d2b0b1a1b6e39a07
2021-06-28Reparent surface control for Webview overlayHuihong Luo
When the root surface control changes, the parent of the Webview surface control must be changed. Bug: 191900007 Test: switch app, or turn on/off screen Change-Id: Ib7b34133776fd5944afc638bfee471afe6a17349
2021-06-24Fix a crash caused by transactionHuihong Luo
A native transaction passed from webview is sent back to native side, so java side does not manage the life cycle of the transaction. Bug: 191414767 Test: Play a video, switch to another app, wait for 10 seconds Change-Id: I013052c202b445438d6cb6497f5f9a2fc22a2b85
2021-06-18Merge "Fix z-order for webview surface control" into sc-devHuihong Luo
2021-06-18Merge "Remove the extra buffer allocation from hwui" into sc-devTreeHugger Robot
2021-06-18Fix z-order for webview surface controlHuihong Luo
Set the root surface control transparent, and set the z order of the newly created child surface control to -1. A new callback is needed to update root surface control in sync from Java side. Bug: 186750329 Test: use latest APKs from Webview team, play a video, mini toolbar should be visible Change-Id: I0b37ee8f83fd2b41ff4f2856dbadd31ff6170baf
2021-06-15Remove the extra buffer allocation from hwuiAdy Abraham
SurfaceFlinger will set the maxAcquiredBufferCount on the buffer queue to account for the extra buffers needed, depends on the refresh rate and app/sf durations, and there is no needed for any addional buffer allocation is hwui. Test: TBD Bug: 188553729 Change-Id: Ic441a6feb15f6b084d45c9e538b11b7b24e36a0e
2021-06-15Add logic to clean up resources more frequentlyNader Jawad
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-05-31Ensure reportFrameMetrics not being called on deleted instanceJorim Jaggi
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-22Use TraceUtils.h from gui shared library.rnlee
Test: It makes Bug: 183120308 Change-Id: I331262dd2da59817031f0c708f4c102041dcb5e0
2021-05-17Use SwapBuffersCompleted as frame end timeJorim Jaggi
...in case GPU completes really quickly. Fixes: 181899835 Test: atest FrameMetricsListenerTest --iterations 50 Change-Id: I73b9380f92eb15f94ae4754746ee98c7fbc4e6c7
2021-05-14Merge "Fix leakage of ASurfaceTransactionCallback" into sc-devHuihong Luo
2021-05-08Ignore blocked-on-sf time for ADPFBo Liu
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-07Fix leakage of ASurfaceTransactionCallbackHuihong Luo
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-04-17Webview overlay supportHuihong Luo
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-14Merge "Fix a logspam" into sc-devJohn Reck
2021-04-13Fix a logspamJohn Reck
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-13Change hwui jank detection to use deadline & gpu completion (1/2)Jorim Jaggi
- 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-08In CanvasContext check at start of frame if GrContext is abandoned.Greg Daniel
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-03-11Send metrics notification just before frame advancesSiarhei Vishniakou
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-05Pass actual present time to ViewRootImplSiarhei Vishniakou
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-02-18Add presentTime to FrameInfoSiarhei Vishniakou
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-17Add GPU completion to FrameMetrics (1/3)Jorim Jaggi
- 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-16Add SurfaceControl to hwuiHuihong Luo
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-08Remove render ahead from hwuiAdy Abraham
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-04Merge "Fix render_ahead properties" into sc-devJohn Reck
2021-02-03Fix render_ahead propertiesJohn Reck
0 and -1 both meant default when 0 should mean 0 and -1 should mean default Test: manual Fixes: 179290765 Change-Id: Ia9aa5e3d83757282bfff776e083d6b3d7d29e9c0
2021-01-29Send input event id to SurfaceFlingerSiarhei Vishniakou
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
2020-10-15HWUI: Finish frame callbacks before framecomplete callbacksVishnu Nair
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-09pass frame deadline to ChoreographerAdy Abraham
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-09-21Merge "Fix override setBufferCount"TreeHugger Robot
2020-09-21Fix override setBufferCountJohn Reck
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-16Shared timeline plumbingSteven Thomas
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-07-30Wire-up colorMode="hdr"John Reck
Fow now it uses a fixed white point of 150nits TBD if this is disabled or adjusted Test: Demo app Change-Id: Iac13597b3d7633fdef3feaf7ec1da0c27c87904c
2020-05-07Avoid excessive KGSL mapsJohn Reck
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-04-30Send drawFinish callback even if did not drawchaviw
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-03-26[HWUI] Add null check for CanvasContextAlec Mouri
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-02-14[HWUI] Remove references to gui/Surface.Alec Mouri
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-13[ANativeWindow] Rename allocateBuffers to tryAllocateBuffersAlec Mouri
Renaming was done in response to API feedback. Bug: 148962594 Test: builds Change-Id: I05b3e99800d967dda243b6e7af48f1b645909bdd
2020-02-06Merge "Ensure SkiaPipeline always has a valid colorspace."Derek Sollenberger
2020-02-06[HWUI] use native_window timestamp apisAlec Mouri
These aren't finalized as stable yet until we sort out some BufferQueue challenges. Bug: 137012798 Test: builds Change-Id: Icd5eb02afc4cf16a2be485e6710f71818b300b9d
2020-02-06Ensure SkiaPipeline always has a valid colorspace.Derek Sollenberger
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-05Merge "Adjust present time calculation"John Reck
2020-02-03Adjust present time calculationJohn Reck
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[HWUI] Use ANativeWindow_getNextFrameId api.Alec Mouri
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-01-30[HWUI] Hook up ANativeWindow_allocateBuffersAlec Mouri
Bug: 137012798 Test: builds Change-Id: Iefe7b73470cb6229fc72d1a1aa33eceb827f527c