summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/tests/unittests/SchedulerTest.cpp
AgeCommit message (Collapse)Author
2022-03-12Merge SP2A.220305.013Haamed Gheibi
Bug: 220074017 Change-Id: Ic33b5a6c518f7aa587e6c7cf0bfd6df4c795782b
2021-07-02SF: Move desired active mode management to DisplayDeviceAdy Abraham
SF would set the desired active mode on the specific DisplayDevice the mode was requested and use it to swicth the active display mode. Change-Id: Ib4f01ec63b2087ab2a81490051d1e029afc71854 Test: SF unit tests Test: refresh rate switching is working on device with more than one display Bug: 187539899 Change-Id: Ie0e5ffe364f81775c2101ffd0cf2c596051947fa Merged-In: Ie0e5ffe364f81775c2101ffd0cf2c596051947fa
2021-07-02SF: add PhysicalDisplayId to DisplayModeAdy Abraham
A DisplayMode should include the PhysicalDisplayId it belongs to we could use that to know which display the mode belogs to. Change-Id: I781cf30c5ccf886f061a45073b369b4f04cc9140 Bug: 187539899 Test: SF unit tests Test: refresh rate switching is working on device with more than one display Change-Id: I9c73b43384cbe934f7584695e5fe5c53ab402bfb Merged-In: I9c73b43384cbe934f7584695e5fe5c53ab402bfb
2021-07-01SF: move RefreshRateConfigs to DisplayDeviceAdy Abraham
Move RefreshRateConfigs to DisplayDevice to be able to maintain a per-display refresh rate switching policy. Test: SF unit tests Test: refresh rate switching is working on device with more than one display Bug: 187539899 Change-Id: Ica6a955e8ad0e563a0740f6579b61fc592eb982c
2021-07-01SF: default display is active displayAdy Abraham
For devices with multiple internal displays, choose the internal display the is powered on (if any) to be the default display that would be used mainly for vsync tracking. Bug: 187539899 Test: SF unit tests Change-Id: Icc305cdeec1c8a04729f00ff795dfbb806d8f72c Merged-In: Icc305cdeec1c8a04729f00ff795dfbb806d8f72c
2021-06-30Merge SP1A.210624.001Scott Lobdell
Change-Id: I4e775a8f840540a8644ecfe3cf33ba1bffe7b8c5
2021-06-22Merge SP1A.210616.001Daniel Norman
Change-Id: I44a5ef0c7858857635265f5dc64a92ebd4b367c3
2021-06-17SF: change acquired buffers based on the current refresh rateAdy Abraham
BLASTBufferQueue set the max acquired buffers based on SF vsync configuration (sf.duration and app.duration). This is calculated based on the max supported refresh rate on the device, and it turn is propogated to apps via min_undequeued_buffers to the app could allocate enough buffers for maintaining the pipeline SF expects. This leads to a higher latency when the device is running in a lower refresh rate as there are more buffers on the buffer queue then required. In this change we are holding on the these "extra buffers" and not releasing them back to the buffer queue so the app would use the number of buffers it needs based on the current refresh rate, and to avoid having unnecessary long latency. Bug: 188553729 Test: Run backpressure based game on 60Hz and 120Hz and collect systraces Change-Id: I9d4e6278f0ddd28008ac437ab0576aa79d05166a
2021-06-14SF: Move mode caching from Scheduler to RefreshRateConfigsMarin Shalamanov
In the existing behavior Scheduler checks if the layerReuquirements have changes since the last time and only then calls into RefreshRateConfigs to getBestRefreshRate. There are two problems with that 1. on the first iteration of the algorithm mFeatures.contentRequirements is empty. If we happen to have an empty list of current content requirements (for example if all layers have NoVote), we won't execute the refresh rate selection algorithm and we'll end up with a wrong initial refresh rate. 2. the cached value needs to be invalided when one of these change - globalSignals - supported display modes (happens on TV) - display manager policy Bug: 188872896 Test: atest SchedulerTest RefreshRateConfigsTest Change-Id: I101f401522fae8358752e283d8375caa93957b6a
2021-06-14SF: Always create LayerHistory in SchedulerMarin Shalamanov
Currently if Scheduler is created when there is only one supported display mode, LayerHistory is not created. This optimization assumes that the list of supported modes is never going to change but this is not the case for TV devices. The typical use case is when a TV dongle or set-top box is first connected to a display after it boots. In this cas some devices will first report only one display mode and later update to the full list of supported modes. This CL changes the behaviour to always have an instance of LayerHistory. If there's only one display mode recordLayerHistory() and chooseRefreshRateForContent() are noops. The alternative to create LayerHistory on demand is more cumbersome because we also would need to register all already created layers. Bug: 188872896 Test: presubmit Change-Id: Ia236fd4a81cc736c172220ff60762ddbc3cbb83a
2021-04-13sf: Trigger early refresh before coming out of idle.Pullakavi Srinivas
-- Upon receiving app's request for vsync, trigger sf refresh if display is in idle. CRs-Fixed: 2786504 Change-Id: Icb49a001f5f6a6f33d52950ecd464a6aac0b5147
2021-03-05Fix memory leaks in libsurfaceflinger_unittestAdy Abraham
Every class that inherits from RefBase must be held by an sp<>. Creating a RefBAse object without an sp<> causes a memory leak. Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest Bug: 181807839 Change-Id: I37ec274b01c5212a5a3cecc2e1eb5b4c9d6122f4
2021-02-09Merge "SurfaceFlinger: expose vsync id extra buffers" into sc-devAdy Abraham
2021-02-05SurfaceFlinger: expose vsync id extra buffersAdy Abraham
Expose a function for clients to call and query the number of extra buffers needed when vsync id is passed with the buffer. Test: launch an app and observe systrace Test: SF unit tests Bug: 178148035 Change-Id: Icbeec66073feeae9768f0dcc45831b26144ab6f6
2021-02-05Rename DisplayConfig to DisplayModeMarin Shalamanov
This CL continues the raneming of display "configs" to display "modes". The goal of this is to have the same names as in the java code and the public display APIs. Additionally in this CL we move DisplayConfig (from libui) to the namespace android::ui. This is to prevent conflict with the SurfaceFlinger's internal android::DisplayMode. This is consistent with the neighboring classes which are also in the ui namespace. Also the type of the parameter defaultMode of {s,g}etDesiredDisplayModeSpecs is changed to size_t for consistency with the rest of the code. Appropriate error handling is added for this. Bug: 159590486 Bug: 179158858 Test: presubmit Change-Id: I31e5be1f2223a9ec9340789ce3dc5738eceaf40f
2021-01-22SF: Rename HwcConfigIndexType to DisplayModeIdMarin Shalamanov
Bug: 159590486 Bug: 176148651 Test: atest libsurfaceflinger_unittest Change-Id: Ie177b213bb7a8ab9f67a51d2b5cf27d8fd97b780
2021-01-15SF: Remove display config functions from HWC2Marin Shalamanov
HWC2 is unnecessary stateful stopgap between HWComposer and ComposerHal. In this CL the following functions are removed from HWC2 * getActiveConfig * getActiveConfigIndex * getDisplayVsyncPeriod and ComposerHal is called directly from HWComposer. This way display configs are stored only in HWComposer. Additionally HWC2::Display::Config is renamed to DisplayMode and it's extracted in its own file. From the perspective of SurfaceFlinger this CL is not modifying behaviour. Bug: 159590486 Bug: 175678215 Test: atest libsurfaceflinger_unittest Change-Id: I8cb450209adf038d891cff00d1c2690c8e6d94f7
2020-12-01Merge changes from topic "deprecate-content-detection-v1"Marin Shalamanov
* changes: Move LayerHistoryV2 to LayerHistory SF: Deprecate content detection v1
2020-11-24SF: Deprecate content detection v1Marin Shalamanov
Remove the code for the old content detection algorithm, which is no longer used. Bug: 174120566 Test: presubmit Change-Id: I0828bcb886f32ec2ebc896848b72340862613100
2020-11-18SurfaceFlinger: Add DISPLAY_EVENT_FRAME_RATE_OVERRIDEAdy Abraham
Add a new event to DisplayEventReceiver that conveys a list of apps whose frame rates have been overriden. This event is processed by the DisplayManager to advertise the new frame rate to the overridden app. Change-Id: I89fce8b5b4d9db65ec5db7dd2393c384c0fcfd82 Bug: 169271059 Bug: 169271062 Bug: 170503758 Test: manual test using SF backdoor
2020-11-03SurfaceFlinger: throttle applications based on uidAdy Abraham
Add the ability for SurfaceFlinger to be able to throttle down to a divider of the refresh rate (i.e. for 30/45 for 90Hz) Change-Id: I6bfd6f43ee1f30e771a136c558d8ae9a6d7fbe0f Test: Manually via 1039 SF backdoor Bug: 170502573 Bug: 169270763 Bug: 169271059
2020-09-25Fixing threading around mConnections in SchedulerAna Krulec
The following happens when we create connection 1. initScheduler() 2. getFactory().createScheduler() 3. mTouchTimer.emplace 4. mScheduler->createConnection Which means that timer created in step 3 expires exactly while we are in step 4, so then the EventThread is half baked in rare cases and we crash. Also, do not continue to calling functions if the optional fields do not have a value. Test: libsurfaceflinger_unittest --gtest_filter=SchedulerTest.testDispatchCachedReportedConfig Bug: 160926398 Change-Id: Ib2617b914145bc4180cc7ca27203c59dbd625c94
2020-08-24SurfaceFlinger: use duration instead of offsetAdy Abraham
This change is using the duration given to sf/app without converting them back to the legacy offset. This allows us to get the expected vsync associated with a wakeup event. This change also required some refactoring: - Move the periodic callback interface out of DispSync and in to DispSyncSource - Translate legacy offsets to duration in case that duration is not specified in the build files - Add support to VSD to expose the deadline timestamp of when a frame needs to be ready by Bug: 162888874 Test: SF unit tests Test: examine systraces Change-Id: I87a53cc7dea931d3c195eab6842e003ca4516885
2020-08-05Merge "Use type safe display IDs."Marin Shalamanov
2020-08-03SF: Remove EventControlThreadDominik Laskowski
EventControlThread was a HWC workaround dating back to K for toggling VSYNC off the main thread, but as of R it defers back to main only to incur context switches. Clean up TestableScheduler construction to skip creating DispSync and timer threads, which fixes several gMock warnings of unexpected calls. Remove virtual destructors for non-polymorphic interfaces. Bug: 160012986 Test: systrace Test: libsurfaceflinger_unittest Change-Id: I01360016a7dba79dc905f250753e6fce34af0a90
2020-07-31Use type safe display IDs.Marin Shalamanov
Use a type safe wrapper around uint64_t for display ids. We also modify the format of the EDID generated physical display IDs by setting bit 62 to 1, which will indicate that the display id is stable across reboot. Bug: 160679868 Test: m && flash device Test: take screnshot on device Test: atest surfaceflinger_unittest Change-Id: Ie2c7c2b737e0882fa4208c059caa85b7ded922b2
2020-07-13SF: Short-circuit scheduler content detectionDominik Laskowski
Avoid registering, recording, partitioning, and transforming layers for content detection in the scheduler if there is a single refresh rate config. Dump content detection version, and layer history stats. Bug: 158780872 Test: No layer history on crosshatch, ARC, etc. Test: dumpsys SurfaceFlinger --vsync Test: libsurfaceflinger_unittest Change-Id: Ia23a35cd6aa0cb117b19c98f5d0af8c14836430e
2020-04-10SurfaceFlinger: Consider resolution when switching refresh rateAdy Abraham
Do not change refresh rate across configs with multiple resolutions Bug: 150237118 Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest Change-Id: I9b0f355a72343cf120229b98e6ad082ea75d3080
2020-02-10[SfStats] Record vsync event connection countAlec Mouri
Bug: 135480141 Test: ./statsd_testdrive 10062 Change-Id: I220f0c96935c96afea194ed8ca69922785cf296e
2020-02-06SF: Remove refresh_rate_switching flag. With a fix.Ana Krulec
ag/9294789 introduce a flag to only allow refresh rate switching on the devices that have that flag set to true, because it broke devices that didn't support multiple refresh rates, and Android TV. LocalDisplayAdapter sets the refresh rate to default when booting the phone, so no need for that in SF anymore. Test: Turn off Smooth display (see b/148821456), device doesn't crash. Test: Install on devices that doesn't have multiple refresh rates. Test: Run SF unittests. Test: Turn on all the flags, and run through set of examples: Video playback stays at 60. Camera stays at 60. Maps play at 60. Low brightness stays at 90. Swappy successfully switches between 60 & 90. Test: Turn off all the flags, and rerun the examples from previous. If applications requested the change, the change is honored, otherwise we stay at default (set by DM). Test: Ask Android TV team to test the patch. Bug: 148427603 Bug: 148821456 Change-Id: I5bb964572d93e5cb78d7b75054b900917be563b0
2020-02-04Revert "Revert "Revert "SF: Remove refresh_rate_switching flag."""Ana Krulec
This reverts commit aa52b007cb5c96d6124a293ca80c430c7051f7f3. Reason for revert: The original revert cause a failure: b/148821456. So the revert was created. Which caused a build failure b/148835312. Reverting the original change and fixing the test (that caused build failure) with it. Bug: 148835312 Bug: 148821456 Bug: 148835894 Test: build, install on coral. Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest Change-Id: I48964c7c27ef53e8fb03d959ef85ee2ec64e1ed1
2020-02-04Revert "Revert "SF: Remove refresh_rate_switching flag.""Christoffer Quist Adamsen
This reverts commit 2a215191be4854fcb4b2836929a955157eae52d1. Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?branch=git_master&target=hawk-userdebug&lkgb=6180052&lkbb=6180424&fkbb=6180072, bug b/148835312. Bug: 148835312 Change-Id: Ie8e5d4c683ab7f10051e355a62941bdb37a196b7
2020-02-04Revert "SF: Remove refresh_rate_switching flag."Ady Abraham
This reverts commit 8c6f3f6bd0c5edce7aa9bfd61b64dd2e7dc43deb. Reason for revert: Crashes on ToT (b/148822765, b/148821456) Change-Id: If1bc13b33321727244c3b0f15a0e7b30665d1c43
2020-01-31SF: Remove refresh_rate_switching flag.Ana Krulec
ag/9294789 introduce a flag to only allow refresh rate switching on the devices that have that flag set to true, because it broke devices that didn't support multiple refresh rates, and Android TV. LocalDisplayAdapter sets the refresh rate to default when booting the phone, so no need for that in SF anymore. Test: Install on devices that doesn't have multiple refresh rates. Test: Run SF unittests. Test: Turn on all the flags, and run through set of examples: Video playback stays at 60. Camera stays at 60. Maps play at 60. Low brightness stays at 90. Swappy successfully switches between 60 & 90. Test: Turn off all the flags, and rerun the examples from previous. If applications requested the change, the change is honored, otherwise we stay at default (set by DM). Test: Ask Android TV team to test the patch. Bug: 148427603 Change-Id: I44085e91a74902d102bcf9f1491164cdb50650cc
2020-01-23SurfaceFlinger: enhance refresh rate selectionAdy Abraham
Enhance the refresh rate selection algorithm to allow having multiple refresh rate. The new process attaches scores to each one of the available refresh rate and chooses the refresh rate with the highest score. This behavior is currently controlled by the sysprop flag 'debug.sf.use_content_detection_v2' and currently turned off. This algorithm stills needs some tunings which will be done in layer CLs. Test: adb shell /data/nativetest64/SurfaceFlinger_test/SurfaceFlinger_test Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest Test: go/90hzscenarios manual tests Bug: 147516364 Fixes: 146068419 Change-Id: I06e07459e469482799ff80fa54fa8dd311325e0e
2020-01-15SurfaceFlinger: Enable -WConversion in Android.bpAdy Abraham
Enable global -WConversion in Android.bp and turn it off in individual files. This is the first step to enable -WConversion in SurfaceFlinger. Test: boot Bug: 129481165 Change-Id: Ia752df39ef380bde71705a32582d618242c466f7
2019-12-05SurfaceFlinger: use config groupsAdy Abraham
Composer 2.4 adds a new attribute for configs groups. This change groups configs according to their group and store them in RefreshRateConfigs. Test: rev up composer to 2.4 and test refresh rate switching Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest Test: adb shell /data/nativetest64/SurfaceFlinger_test/SurfaceFlinger_test Bug: 141329414 Fixes: 139751853 Change-Id: Ic0bcd3da4bf6b73efa11a60c2594948ce030362f
2019-09-18SF: Hook up VSYNC injection to SchedulerDominik Laskowski
This CL refactors VSYNC injection to interface with the Scheduler API, and removes otherwise unused EventThread members. Bug: 128863962 Test: sffakehwc_test Change-Id: I2ba143bb78baf3e66a47b90163eacf0d0e431124
2019-09-12Add a flag for refresh rate switchingSteven Thomas
Some devices don't do refresh rate switching, so we should take that into account when filtering display manager config settings and deciding scheduling behavior. This CL adds a sysprop that can be set to indicate if surface flinger should do refresh rate switching, and modifies surface flinger to have the correct behavior when we're not doing refresh rate switching. Bug: 136592946 Bug: 138261472 Test: Ran through various 60/90 switching scenarios on a device with refresh rate switching. Test: Set the refresh rate switching sysprop to false, and confirmed we get a consistent 60Hz. Test: Inspected dumpsys output and confirmed it looks correct. In particular, refresh rate stats are output correctly. Test: Ran automated tests: RefreshRateConfigsTest, RefreshRateStatsTest, SchedulerTest. Change-Id: I54cd5be9d2c1b9abc8475c3ce39846cbe9f9fe53
2019-08-16SF: Clean up SchedulerDominik Laskowski
Remove dynamic allocation for Scheduler::{Connection,ConnectionHandle}, as well as ref-counting for the latter. Also, remove dead code and make members private. Bug: 130554049 Test: libsurfaceflinger_unittest Change-Id: Ibb9dc8d4cb66451a4172c852a36032bbc0a54411
2019-06-13Merge "SurfaceFlinger: Some fixes to DispSync" into qt-r1-devAdy Abraham
2019-06-10SurfaceFlinger: Some fixes to DispSyncAdy Abraham
Pass negative offsets to DispSync to fix the scheduling when SurfaceFlinger uses negative offsets. Change-Id: I1f9544b064305c87f973120cc1bc59a0268b78e5 Bug: 132284303 Test: UI-Bench
2019-06-05SurfaceFlinger: add explicit register for DISPLAY_EVENT_CONFIG_CHANGEDAdy Abraham
When display refresh rate changes, SF fires DISPLAY_EVENT_CONFIG_CHANGED thru DisplayEventReceiver. If the other end of the pipe doesn't consume the events it may lead to pipe full and dropping of events. Furthermore, The only clients interested in this event in DisplayManager and hwui. To avoid spamming all clients with this event, this change is adding an explicit register for DISPLAY_EVENT_CONFIG_CHANGED events. Bug: 131688378 Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest Test: trigger config change and observe logcat Change-Id: I5973a1ecc1f3e3ff8d8a0cba19db0e49ef0d5341
2019-05-17SurfaceFlinger: Add touch events to SchedulerAdy Abraham
Add the notion of Touch Events to Scheduler to enhance the algorithm to move to Performance refresh rate. Scheduler selects Performance when: - There is a touch event - There is a buffer to HWC This change also removes the behavior of Scheduler to move to Performance on Choreographer callbacks. Test: Switch between apps using gesture navigation Bug: 131906818 Change-Id: I588cfc32449e87744e829dc7c5261a2e4151a8f8
2019-04-08SF: Updating content FPS trackingAdy Abraham
1) Each time SF creates a layer, register it with Scheduler and return handle 2) BufferQueueLayer and BufferStateLayer can now send information about buffers for given layers via layer handle. Algorithm for detecting content fps: 1) Keep the refresh rate per layer (explicit timestamp, or 0). 2) Keep information about last 10 present or update timestamps. This will be an indicator for precedence. 3) Choose the MAX refresh rate among last updated layers. For more info see go/surface-flinger-scheduler and go/content-fps-detection-in-scheduler Test: Updating unit tests. Systrace. Change-Id: I988a7a79e9a9f0f61674c9b637c5142db3336177 Bug: 127727337
2019-02-11SurfaceFlinger: Scheduler: move reset callback to scheduler threadAdy Abraham
Dispatch timer reset callback from Scheduler's thread. This would make both Scheduler callbacks (idle timer and reset timer) to be dispatched from the same context and avoid any potential deadlocks. Test: surfaceflinger unit tests Change-Id: Iad7d10b85db090662f9b7c4ffb45ed9110035ea4
2019-02-06SF: Fix thread safety for scheduler callbacksDominik Laskowski
SurfaceFlinger::setRefreshRateTo, called from the Scheduler callbacks, reads HWC and SF state without locking mStateLock, concurrently with writes from the main thread. This CL registers ResetIdleTimerCallback per EventThreadConnection, and locks mStateLock for connections used off the main thread. Note that ExpiredTimerCallback locks mStateLock unconditionally, since it is always called from the IdleTimer thread. This CL also adds a thread annotation to setRefreshRateTo, and refactors it accordingly. Bug: 123715322 Test: libsurfaceflinger_unittest Test: Boot with scheduler enabled Change-Id: Id62c48ae22da38f292ffc18e8731a1c49a0a083c
2019-02-02SF: Plumb physical display IDs to libguiDominik Laskowski
This CL replaces ISurfaceComposer::{eDisplayIdMain,eDisplayIdHdmi} with the stable 64-bit display IDs generated by SF. Note that the 64-bit IDs fall back to the old values if the HWC API for display identification is not supported. Bug: 74619554 Test: LocalDisplayAdapter and Choreographer receive 64-bit IDs Test: 64-bit IDs fall back to 0 and 1 on HWC 2.2 and below Change-Id: I3c08eff6eb8bb179ecce596ab2820a2aa44c8649
2019-01-28SF: Fix stray pointers in SchedulerDominik Laskowski
Bug: None Test: Build Change-Id: I578fc0d94691edcd905f78bc75e08072d9c49744
2019-01-14SF: Register resync callback per event connectionDominik Laskowski
This CL ties the resync callback to an EventThreadConnection instead of an EventThread. This is a step towards having IDisplayEventConnection subscribe to a given display rather than the primary display implicitly. Each display will then have SurfaceFlinger::VsyncState that resyncs independently at potentially different rates. Callbacks have weak references to the per-display VsyncState owned by SurfaceFlinger. Bug: 74619554 Test: Boot and turn display on/off repeatedly Change-Id: Ic7cc64e2004fa07a5d54431fc330995048a4ed20