summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
AgeCommit message (Collapse)Author
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-04-13Change hwui jank detection to use deadline & gpu completion (2/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: Ia1cae9f0c5358d1cd3bf043289ea8b4d26154737
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
2020-12-24SF: Compile with -WextraMarin Shalamanov
Compile with -Wextra for additional conversion checks. In each file which produces compile errors -Wextra is ignored. Bug: 175126758 Test: m surfaceflinger && m libsurfaceflinger_unittest Change-Id: Iec6bcc699715a99c8c65d891ab3c0481e884c728
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-17Enable SurfaceFlinger to use FrameTimelineAdithya Srinivasan
This change adds the necessary plumbing from SurfaceFlinger to use FrameTimeline for the BufferQueueLayers. Bug: 162890590 Test: libsurfaceflinger_unittest Change-Id: Ibac00ccb6584e9eb8d06eb9682747400b3e92845
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-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-04-23SurfaceFlinger: expected present time directly from VSyncReactorAdy Abraham
When SurfaceFlinger calculates what is the vsync time, it does that by asking VSyncReactor what is next anticipated vsync from the wake up time. To handle negative offsets (when SF wakes up more than a vsync period before a vsync event) SF adds a vsync period to that anticipated vsync. This creates a race condition where the offset used at the time of invalidate may be different than the offset used by VSyncReactor calculated at the time of the requestNextVsync(). To fix that, we plumb the first calculated vsync time to SurfaceFlinger. Bug: 154303002 Test: Run app transitions and collect systrace Change-Id: I3f2670c7b0ecb52a85fb07df6d360694b51d5d66
2020-03-24SurfaceFlinger: add debug information when vsync is not generatedAdy Abraham
Print debug information about VsyncReactor internal state when we expect a vsync event but it is not generated. Bug: 151892277 Test: adb shell dumpsys SurfaceFlinger --dispsync Test: simulate a missed vsync and observed logcat Change-Id: Ia98cb884321d0c25610c4d721f422d9cd05c8c5e
2020-02-10[SfStats] Record vsync event connection countAlec Mouri
Bug: 135480141 Test: ./statsd_testdrive 10062 Change-Id: I220f0c96935c96afea194ed8ca69922785cf296e
2019-12-26[AChoreographer] Add refresh rate callback.Alec Mouri
This will augment the NDK to respond to display events where the display refresh rate changes. Consumers of this api will include: * HWUI, for implementing a policy for determining whether to use render-ahead, * Swappy, to potentially replace jumping into Java from native code to respond to display evnets there. * Any other native app that would rely on the up-to-date display refresh rate. Currently however this is not yet exposed to NDK as CTS is not yet written. Once CTS is written then this will be formally exposed to NDK. For now we'll leave these as APEX apis to represent incremental progress. Bug: 136262896 Test: builds Change-Id: I66d393f93eb5d681547411e330ef1b8950a35c5d
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-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-09Remove app vsync pausingAlec Mouri
Bug: 128849305 Change-Id: I97c7ab9a2555f229783cd1c5352d883a627ab193 Test: jank tests Test: systrace
2019-03-28SurfaceFlinger: fix invalid PhysicalDisplayId in onConfigChanged eventAdy Abraham
A conversion error (uint64_t -> uint32_t) was causing a trunction of displayId value which lead to invalid displayId in onConfigChanged. Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest Bug: 129159940 Change-Id: I9d24cac0b9e74c7b20421d2b7d9fd65c16cca9e1
2019-02-25SurfaceFlinger: add DISPLAY_EVENT_CONFIG_CHANGEDAdy Abraham
Add a new event to DisplayEventReceiver for display configuration change. This event is sent by SF when display config is changed. Test: adb shell /data/nativetest64/libsurfaceflinger_unittest/libsurfaceflinger_unittest Bug: 122905403 Change-Id: Ibb7e0ce7b83b91259ccb0e9c982f5e378b0ebfaf
2019-02-19SurfaceFlinger: no app vsyncs during config switchAdy Abraham
Do not dipatch vsync callbacks to applications during a config switch as applications will get choreographer callbacks at uneven times and will stuff the queue to surface flinger. Test: test google/perf/jank/UIBench/UIBench-Trace:com.android.uibench.janktests.UiBenchJankTests#testClippedListView -v Change-Id: I0537933c27af83a9186bcff54c3596d612c748ea
2019-02-08Merge "SF: Fix thread safety for scheduler callbacks"TreeHugger Robot
2019-02-07Merge "SF: Fix for rare flakes in Event{Control}ThreadTests"TreeHugger Robot
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-02-01SF: Fix for rare flakes in Event{Control}ThreadTestsLloyd Pique
This has been a minor issue for a while, and was causing a few failures a week in the continuous testing infrastructure. I managed to reproduce it locally with 10k iterations of one test (to even have a good chance of catching one failure!) -- on a phone that was stuck in a startup boot crash loop! (Other significant activity), and from there diagnose it to an extremely rare chance that threads would take 20-30ms to resume execution after being unblocked, significantly more than the 10ms maximum time allowed. This patch increases the maximum wait time to 100ms which should eliminate the flakes (or at least reduce them to an substantially smaller percentage of the time). This led to the discovery that the EventThreadTest destructor was using the call for expecting an event when actually it should have been making a call using a lower default threshhold to detect unexpected calls, which I fixed. With the tests otherwise using the calls as intended, I verified that the typical test time was not substantially slower than it was before (in fact it was faster after the EventThreadTest fix!) Bug: 112104412 Test: atest libsurfaceflinger_unittest # Not slower for a typical run Test: EventControlThreadTest.signalsVSyncEnabledThenDisabled * 100k Change-Id: Ie778567955d746922ef514baff1a552c34794b8d
2019-01-30SF: Fix contradiction in EventThreadTestDominik Laskowski
The test was invoking a VSYNC callback right after checking that VSYNC callbacks are not enabled. Bug: 123530318 Test: vsyncRequestIsIgnoredIfDisplayIsDisconnected Change-Id: I5cc997266450e1ecb6ed2cd3901472984053477a
2019-01-28SF: Tie VSyncState lifetime to display hotplugDominik Laskowski
This CL creates/destroys EventThread::VSyncState when the display is connected/disconnected. Bug: 74619554 Test: libsurfaceflinger_unittest Test: dumpsys SurfaceFlinger --vsync Change-Id: I46dad4857222b6d2932ab568c4d66325edc3371b
2019-01-26SF: Toggle VSYNC in EventThread with state machineDominik Laskowski
This CL simplifies the logic to enable and disable VSYNC in the EventThread loop. Bug: 74619554 Test: libsurfaceflinger_unittest Test: dumpsys SurfaceFlinger --vsync Change-Id: I7637fcf1982d60cfced5dae68c74556f0ee67a0f
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
2019-01-11SF: Adding callback to Scheduler for setting refresh rate to 60 and 90.Ana Krulec
When device is idle, refresh rate is set to 60. When not it's set to 90. See go/surface-flinger-scheduler for more info. Test: All SF tests pass. Bug: 113612090 Bug: 122347908 Change-Id: Ica6e483118db276f72d3cb4e79535303c76f99d7
2018-12-27SF: Moving EventThread::Connection out of impl classAna Krulec
This is part of Scheduler refactoring. EventThread::Connection should be a wrapper that translates IDisplayEventConnection into EventThread calls. Test: SF tests pass. Bug: 113612090 Change-Id: I2bcf0c45a33638c59f7828085c563dbc52b2d66e
2018-08-09SF: Move relevant scheduler files into one directory.Ana Krulec
Scheduler (see go/surface-flinger-scheduler) is going to live in its own directory. This CL just moves the relevant files into that directory. No changes to business logic. Test: all SF tests pass. Change-Id: Iff0717f9867316b28e68fd8311bd9fdc4e029951
2018-06-19SF: Decouple EventThread from DisplayDeviceDominik Laskowski
EventThread uses DisplayDevice::DisplayType constants, which will be removed in a follow-up CL. This CL replaces them with local constants as a stopgap until stable display IDs are propagated through the SF/WM interface. Bug: 74619554 Test: libsurfaceflinger_unittest Change-Id: I68be363dc58c5e3aa17d05fba156d520a01fa775
2018-05-14SF: Test coverage for EventThreadLloyd Pique
Add a unit test to cover EventThread.cpp Test: atest libsurfaceflinger_unittest Bug: 74827900 Change-Id: If9479cd9deedff836068cb53e7da2cb64041aea1