Loading services/surfaceflinger/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -52,6 +52,7 @@ cc_defaults { "libpdx_default_transport", "libpdx_default_transport", "libprocessgroup", "libprocessgroup", "libprotobuf-cpp-lite", "libprotobuf-cpp-lite", "libstatslog", "libsync", "libsync", "libtimestats", "libtimestats", "libui", "libui", Loading services/surfaceflinger/SurfaceFlinger.cpp +75 −43 Original line number Original line Diff line number Diff line Loading @@ -21,28 +21,17 @@ //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #define ATRACE_TAG ATRACE_TAG_GRAPHICS #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include <sys/types.h> #include "SurfaceFlinger.h" #include <errno.h> #include <dlfcn.h> #include <algorithm> #include <cinttypes> #include <cmath> #include <cstdint> #include <functional> #include <mutex> #include <optional> #include <unordered_map> #include <android/configuration.h> #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> #include <android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h> #include <android/hardware/configstore/1.1/types.h> #include <android/hardware/power/1.0/IPower.h> #include <android/native_window.h> #include <android/native_window.h> #include <cutils/properties.h> #include <log/log.h> #include <binder/IPCThreadState.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binder/IServiceManager.h> #include <binder/PermissionCache.h> #include <binder/PermissionCache.h> #include <compositionengine/CompositionEngine.h> #include <compositionengine/CompositionEngine.h> #include <compositionengine/CompositionRefreshArgs.h> #include <compositionengine/CompositionRefreshArgs.h> #include <compositionengine/Display.h> #include <compositionengine/Display.h> Loading @@ -51,10 +40,14 @@ #include <compositionengine/OutputLayer.h> #include <compositionengine/OutputLayer.h> #include <compositionengine/RenderSurface.h> #include <compositionengine/RenderSurface.h> #include <compositionengine/impl/OutputCompositionState.h> #include <compositionengine/impl/OutputCompositionState.h> #include <configstore/Utils.h> #include <cutils/compiler.h> #include <cutils/properties.h> #include <dlfcn.h> #include <dvr/vr_flinger.h> #include <dvr/vr_flinger.h> #include <errno.h> #include <gui/BufferQueue.h> #include <gui/BufferQueue.h> #include <gui/DebugEGLImageTracker.h> #include <gui/DebugEGLImageTracker.h> #include <gui/GuiConfig.h> #include <gui/GuiConfig.h> #include <gui/IDisplayEventConnection.h> #include <gui/IDisplayEventConnection.h> #include <gui/IProducerListener.h> #include <gui/IProducerListener.h> Loading @@ -63,7 +56,13 @@ #include <gui/LayerState.h> #include <gui/LayerState.h> #include <gui/Surface.h> #include <gui/Surface.h> #include <input/IInputFlinger.h> #include <input/IInputFlinger.h> #include <layerproto/LayerProtoParser.h> #include <log/log.h> #include <private/android_filesystem_config.h> #include <private/gui/SyncFeatures.h> #include <renderengine/RenderEngine.h> #include <renderengine/RenderEngine.h> #include <statslog.h> #include <sys/types.h> #include <ui/ColorSpace.h> #include <ui/ColorSpace.h> #include <ui/DebugUtils.h> #include <ui/DebugUtils.h> #include <ui/DisplayConfig.h> #include <ui/DisplayConfig.h> Loading @@ -80,8 +79,14 @@ #include <utils/Trace.h> #include <utils/Trace.h> #include <utils/misc.h> #include <utils/misc.h> #include <private/android_filesystem_config.h> #include <algorithm> #include <private/gui/SyncFeatures.h> #include <cinttypes> #include <cmath> #include <cstdint> #include <functional> #include <mutex> #include <optional> #include <unordered_map> #include "BufferLayer.h" #include "BufferLayer.h" #include "BufferQueueLayer.h" #include "BufferQueueLayer.h" Loading @@ -90,23 +95,19 @@ #include "Colorizer.h" #include "Colorizer.h" #include "ContainerLayer.h" #include "ContainerLayer.h" #include "DisplayDevice.h" #include "DisplayDevice.h" #include "EffectLayer.h" #include "Layer.h" #include "LayerVector.h" #include "MonitoredProducer.h" #include "NativeWindowSurface.h" #include "RefreshRateOverlay.h" #include "StartPropertySetThread.h" #include "SurfaceFlinger.h" #include "SurfaceInterceptor.h" #include "DisplayHardware/ComposerHal.h" #include "DisplayHardware/ComposerHal.h" #include "DisplayHardware/DisplayIdentification.h" #include "DisplayHardware/DisplayIdentification.h" #include "DisplayHardware/FramebufferSurface.h" #include "DisplayHardware/FramebufferSurface.h" #include "DisplayHardware/HWComposer.h" #include "DisplayHardware/HWComposer.h" #include "DisplayHardware/VirtualDisplaySurface.h" #include "DisplayHardware/VirtualDisplaySurface.h" #include "EffectLayer.h" #include "Effects/Daltonizer.h" #include "Effects/Daltonizer.h" #include "FrameTracer/FrameTracer.h" #include "FrameTracer/FrameTracer.h" #include "Layer.h" #include "LayerVector.h" #include "MonitoredProducer.h" #include "NativeWindowSurface.h" #include "RefreshRateOverlay.h" #include "RegionSamplingThread.h" #include "RegionSamplingThread.h" #include "Scheduler/DispSync.h" #include "Scheduler/DispSync.h" #include "Scheduler/DispSyncSource.h" #include "Scheduler/DispSyncSource.h" Loading @@ -115,23 +116,13 @@ #include "Scheduler/MessageQueue.h" #include "Scheduler/MessageQueue.h" #include "Scheduler/PhaseOffsets.h" #include "Scheduler/PhaseOffsets.h" #include "Scheduler/Scheduler.h" #include "Scheduler/Scheduler.h" #include "StartPropertySetThread.h" #include "SurfaceFlingerProperties.h" #include "SurfaceInterceptor.h" #include "TimeStats/TimeStats.h" #include "TimeStats/TimeStats.h" #include <cutils/compiler.h> #include "android-base/parseint.h" #include "android-base/parseint.h" #include "android-base/stringprintf.h" #include "android-base/stringprintf.h" #include <android/configuration.h> #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> #include <android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h> #include <android/hardware/configstore/1.1/types.h> #include <android/hardware/power/1.0/IPower.h> #include <configstore/Utils.h> #include <layerproto/LayerProtoParser.h> #include "SurfaceFlingerProperties.h" namespace android { namespace android { using namespace std::string_literals; using namespace std::string_literals; Loading Loading @@ -335,6 +326,9 @@ SurfaceFlinger::SurfaceFlinger(Factory& factory) : SurfaceFlinger(factory, SkipI property_get("ro.bq.gpu_to_cpu_unsupported", value, "0"); property_get("ro.bq.gpu_to_cpu_unsupported", value, "0"); mGpuToCpuSupported = !atoi(value); mGpuToCpuSupported = !atoi(value); property_get("ro.build.type", value, "user"); mIsUserBuild = strcmp(value, "user") == 0; property_get("debug.sf.showupdates", value, "0"); property_get("debug.sf.showupdates", value, "0"); mDebugRegion = atoi(value); mDebugRegion = atoi(value); Loading Loading @@ -1813,6 +1807,10 @@ void SurfaceFlinger::onMessageReceived(int32_t what) NO_THREAD_SAFETY_ANALYSIS { if (frameMissed) { if (frameMissed) { mFrameMissedCount++; mFrameMissedCount++; mTimeStats->incrementMissedFrames(); mTimeStats->incrementMissedFrames(); if (mMissedFrameJankCount == 0) { mMissedFrameJankStart = systemTime(); } mMissedFrameJankCount++; } } if (hwcFrameMissed) { if (hwcFrameMissed) { Loading @@ -1831,6 +1829,40 @@ void SurfaceFlinger::onMessageReceived(int32_t what) NO_THREAD_SAFETY_ANALYSIS { } } } } // Our jank window is always at least 100ms since we missed a // frame... static constexpr nsecs_t kMinJankyDuration = std::chrono::duration_cast<std::chrono::nanoseconds>(100ms).count(); // ...but if it's larger than 1s then we missed the trace cutoff. static constexpr nsecs_t kMaxJankyDuration = std::chrono::duration_cast<std::chrono::nanoseconds>(1s).count(); // If we're in a user build then don't push any atoms if (!mIsUserBuild && mMissedFrameJankCount > 0) { const auto displayDevice = getDefaultDisplayDeviceLocked(); // Only report jank when the display is on, as displays in DOZE // power mode may operate at a different frame rate than is // reported in their config, which causes noticeable (but less // severe) jank. if (displayDevice && displayDevice->getPowerMode() == HWC_POWER_MODE_NORMAL) { const nsecs_t currentTime = systemTime(); const nsecs_t jankDuration = currentTime - mMissedFrameJankStart; if (jankDuration > kMinJankyDuration && jankDuration < kMaxJankyDuration) { ATRACE_NAME("Jank detected"); ALOGD("Detected janky event. Missed frames: %d", mMissedFrameJankCount); const int32_t jankyDurationMillis = jankDuration / (1000 * 1000); android::util::stats_write(android::util::DISPLAY_JANK_REPORTED, jankyDurationMillis, mMissedFrameJankCount); } // We either reported a jank event or we missed the trace // window, so clear counters here. if (jankDuration > kMinJankyDuration) { mMissedFrameJankCount = 0; mMissedFrameJankStart = 0; } } } // Now that we're going to make it to the handleMessageTransaction() // Now that we're going to make it to the handleMessageTransaction() // call below it's safe to call updateVrFlinger(), which will // call below it's safe to call updateVrFlinger(), which will // potentially trigger a display handoff. // potentially trigger a display handoff. Loading services/surfaceflinger/SurfaceFlinger.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -984,6 +984,7 @@ private: // constant members (no synchronization needed for access) // constant members (no synchronization needed for access) const nsecs_t mBootTime = systemTime(); const nsecs_t mBootTime = systemTime(); bool mGpuToCpuSupported = false; bool mGpuToCpuSupported = false; bool mIsUserBuild = true; // Can only accessed from the main thread, these members // Can only accessed from the main thread, these members // don't need synchronization // don't need synchronization Loading Loading @@ -1227,6 +1228,11 @@ private: // Flags to capture the state of Vsync in HWC // Flags to capture the state of Vsync in HWC HWC2::Vsync mHWCVsyncState = HWC2::Vsync::Disable; HWC2::Vsync mHWCVsyncState = HWC2::Vsync::Disable; HWC2::Vsync mHWCVsyncPendingState = HWC2::Vsync::Disable; HWC2::Vsync mHWCVsyncPendingState = HWC2::Vsync::Disable; // Fields tracking the current jank event: when it started and how many // janky frames there are. nsecs_t mMissedFrameJankStart = 0; int32_t mMissedFrameJankCount = 0; }; }; } // namespace android } // namespace android Loading
services/surfaceflinger/Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -52,6 +52,7 @@ cc_defaults { "libpdx_default_transport", "libpdx_default_transport", "libprocessgroup", "libprocessgroup", "libprotobuf-cpp-lite", "libprotobuf-cpp-lite", "libstatslog", "libsync", "libsync", "libtimestats", "libtimestats", "libui", "libui", Loading
services/surfaceflinger/SurfaceFlinger.cpp +75 −43 Original line number Original line Diff line number Diff line Loading @@ -21,28 +21,17 @@ //#define LOG_NDEBUG 0 //#define LOG_NDEBUG 0 #define ATRACE_TAG ATRACE_TAG_GRAPHICS #define ATRACE_TAG ATRACE_TAG_GRAPHICS #include <sys/types.h> #include "SurfaceFlinger.h" #include <errno.h> #include <dlfcn.h> #include <algorithm> #include <cinttypes> #include <cmath> #include <cstdint> #include <functional> #include <mutex> #include <optional> #include <unordered_map> #include <android/configuration.h> #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> #include <android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h> #include <android/hardware/configstore/1.1/types.h> #include <android/hardware/power/1.0/IPower.h> #include <android/native_window.h> #include <android/native_window.h> #include <cutils/properties.h> #include <log/log.h> #include <binder/IPCThreadState.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binder/IServiceManager.h> #include <binder/PermissionCache.h> #include <binder/PermissionCache.h> #include <compositionengine/CompositionEngine.h> #include <compositionengine/CompositionEngine.h> #include <compositionengine/CompositionRefreshArgs.h> #include <compositionengine/CompositionRefreshArgs.h> #include <compositionengine/Display.h> #include <compositionengine/Display.h> Loading @@ -51,10 +40,14 @@ #include <compositionengine/OutputLayer.h> #include <compositionengine/OutputLayer.h> #include <compositionengine/RenderSurface.h> #include <compositionengine/RenderSurface.h> #include <compositionengine/impl/OutputCompositionState.h> #include <compositionengine/impl/OutputCompositionState.h> #include <configstore/Utils.h> #include <cutils/compiler.h> #include <cutils/properties.h> #include <dlfcn.h> #include <dvr/vr_flinger.h> #include <dvr/vr_flinger.h> #include <errno.h> #include <gui/BufferQueue.h> #include <gui/BufferQueue.h> #include <gui/DebugEGLImageTracker.h> #include <gui/DebugEGLImageTracker.h> #include <gui/GuiConfig.h> #include <gui/GuiConfig.h> #include <gui/IDisplayEventConnection.h> #include <gui/IDisplayEventConnection.h> #include <gui/IProducerListener.h> #include <gui/IProducerListener.h> Loading @@ -63,7 +56,13 @@ #include <gui/LayerState.h> #include <gui/LayerState.h> #include <gui/Surface.h> #include <gui/Surface.h> #include <input/IInputFlinger.h> #include <input/IInputFlinger.h> #include <layerproto/LayerProtoParser.h> #include <log/log.h> #include <private/android_filesystem_config.h> #include <private/gui/SyncFeatures.h> #include <renderengine/RenderEngine.h> #include <renderengine/RenderEngine.h> #include <statslog.h> #include <sys/types.h> #include <ui/ColorSpace.h> #include <ui/ColorSpace.h> #include <ui/DebugUtils.h> #include <ui/DebugUtils.h> #include <ui/DisplayConfig.h> #include <ui/DisplayConfig.h> Loading @@ -80,8 +79,14 @@ #include <utils/Trace.h> #include <utils/Trace.h> #include <utils/misc.h> #include <utils/misc.h> #include <private/android_filesystem_config.h> #include <algorithm> #include <private/gui/SyncFeatures.h> #include <cinttypes> #include <cmath> #include <cstdint> #include <functional> #include <mutex> #include <optional> #include <unordered_map> #include "BufferLayer.h" #include "BufferLayer.h" #include "BufferQueueLayer.h" #include "BufferQueueLayer.h" Loading @@ -90,23 +95,19 @@ #include "Colorizer.h" #include "Colorizer.h" #include "ContainerLayer.h" #include "ContainerLayer.h" #include "DisplayDevice.h" #include "DisplayDevice.h" #include "EffectLayer.h" #include "Layer.h" #include "LayerVector.h" #include "MonitoredProducer.h" #include "NativeWindowSurface.h" #include "RefreshRateOverlay.h" #include "StartPropertySetThread.h" #include "SurfaceFlinger.h" #include "SurfaceInterceptor.h" #include "DisplayHardware/ComposerHal.h" #include "DisplayHardware/ComposerHal.h" #include "DisplayHardware/DisplayIdentification.h" #include "DisplayHardware/DisplayIdentification.h" #include "DisplayHardware/FramebufferSurface.h" #include "DisplayHardware/FramebufferSurface.h" #include "DisplayHardware/HWComposer.h" #include "DisplayHardware/HWComposer.h" #include "DisplayHardware/VirtualDisplaySurface.h" #include "DisplayHardware/VirtualDisplaySurface.h" #include "EffectLayer.h" #include "Effects/Daltonizer.h" #include "Effects/Daltonizer.h" #include "FrameTracer/FrameTracer.h" #include "FrameTracer/FrameTracer.h" #include "Layer.h" #include "LayerVector.h" #include "MonitoredProducer.h" #include "NativeWindowSurface.h" #include "RefreshRateOverlay.h" #include "RegionSamplingThread.h" #include "RegionSamplingThread.h" #include "Scheduler/DispSync.h" #include "Scheduler/DispSync.h" #include "Scheduler/DispSyncSource.h" #include "Scheduler/DispSyncSource.h" Loading @@ -115,23 +116,13 @@ #include "Scheduler/MessageQueue.h" #include "Scheduler/MessageQueue.h" #include "Scheduler/PhaseOffsets.h" #include "Scheduler/PhaseOffsets.h" #include "Scheduler/Scheduler.h" #include "Scheduler/Scheduler.h" #include "StartPropertySetThread.h" #include "SurfaceFlingerProperties.h" #include "SurfaceInterceptor.h" #include "TimeStats/TimeStats.h" #include "TimeStats/TimeStats.h" #include <cutils/compiler.h> #include "android-base/parseint.h" #include "android-base/parseint.h" #include "android-base/stringprintf.h" #include "android-base/stringprintf.h" #include <android/configuration.h> #include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h> #include <android/hardware/configstore/1.1/ISurfaceFlingerConfigs.h> #include <android/hardware/configstore/1.1/types.h> #include <android/hardware/power/1.0/IPower.h> #include <configstore/Utils.h> #include <layerproto/LayerProtoParser.h> #include "SurfaceFlingerProperties.h" namespace android { namespace android { using namespace std::string_literals; using namespace std::string_literals; Loading Loading @@ -335,6 +326,9 @@ SurfaceFlinger::SurfaceFlinger(Factory& factory) : SurfaceFlinger(factory, SkipI property_get("ro.bq.gpu_to_cpu_unsupported", value, "0"); property_get("ro.bq.gpu_to_cpu_unsupported", value, "0"); mGpuToCpuSupported = !atoi(value); mGpuToCpuSupported = !atoi(value); property_get("ro.build.type", value, "user"); mIsUserBuild = strcmp(value, "user") == 0; property_get("debug.sf.showupdates", value, "0"); property_get("debug.sf.showupdates", value, "0"); mDebugRegion = atoi(value); mDebugRegion = atoi(value); Loading Loading @@ -1813,6 +1807,10 @@ void SurfaceFlinger::onMessageReceived(int32_t what) NO_THREAD_SAFETY_ANALYSIS { if (frameMissed) { if (frameMissed) { mFrameMissedCount++; mFrameMissedCount++; mTimeStats->incrementMissedFrames(); mTimeStats->incrementMissedFrames(); if (mMissedFrameJankCount == 0) { mMissedFrameJankStart = systemTime(); } mMissedFrameJankCount++; } } if (hwcFrameMissed) { if (hwcFrameMissed) { Loading @@ -1831,6 +1829,40 @@ void SurfaceFlinger::onMessageReceived(int32_t what) NO_THREAD_SAFETY_ANALYSIS { } } } } // Our jank window is always at least 100ms since we missed a // frame... static constexpr nsecs_t kMinJankyDuration = std::chrono::duration_cast<std::chrono::nanoseconds>(100ms).count(); // ...but if it's larger than 1s then we missed the trace cutoff. static constexpr nsecs_t kMaxJankyDuration = std::chrono::duration_cast<std::chrono::nanoseconds>(1s).count(); // If we're in a user build then don't push any atoms if (!mIsUserBuild && mMissedFrameJankCount > 0) { const auto displayDevice = getDefaultDisplayDeviceLocked(); // Only report jank when the display is on, as displays in DOZE // power mode may operate at a different frame rate than is // reported in their config, which causes noticeable (but less // severe) jank. if (displayDevice && displayDevice->getPowerMode() == HWC_POWER_MODE_NORMAL) { const nsecs_t currentTime = systemTime(); const nsecs_t jankDuration = currentTime - mMissedFrameJankStart; if (jankDuration > kMinJankyDuration && jankDuration < kMaxJankyDuration) { ATRACE_NAME("Jank detected"); ALOGD("Detected janky event. Missed frames: %d", mMissedFrameJankCount); const int32_t jankyDurationMillis = jankDuration / (1000 * 1000); android::util::stats_write(android::util::DISPLAY_JANK_REPORTED, jankyDurationMillis, mMissedFrameJankCount); } // We either reported a jank event or we missed the trace // window, so clear counters here. if (jankDuration > kMinJankyDuration) { mMissedFrameJankCount = 0; mMissedFrameJankStart = 0; } } } // Now that we're going to make it to the handleMessageTransaction() // Now that we're going to make it to the handleMessageTransaction() // call below it's safe to call updateVrFlinger(), which will // call below it's safe to call updateVrFlinger(), which will // potentially trigger a display handoff. // potentially trigger a display handoff. Loading
services/surfaceflinger/SurfaceFlinger.h +6 −0 Original line number Original line Diff line number Diff line Loading @@ -984,6 +984,7 @@ private: // constant members (no synchronization needed for access) // constant members (no synchronization needed for access) const nsecs_t mBootTime = systemTime(); const nsecs_t mBootTime = systemTime(); bool mGpuToCpuSupported = false; bool mGpuToCpuSupported = false; bool mIsUserBuild = true; // Can only accessed from the main thread, these members // Can only accessed from the main thread, these members // don't need synchronization // don't need synchronization Loading Loading @@ -1227,6 +1228,11 @@ private: // Flags to capture the state of Vsync in HWC // Flags to capture the state of Vsync in HWC HWC2::Vsync mHWCVsyncState = HWC2::Vsync::Disable; HWC2::Vsync mHWCVsyncState = HWC2::Vsync::Disable; HWC2::Vsync mHWCVsyncPendingState = HWC2::Vsync::Disable; HWC2::Vsync mHWCVsyncPendingState = HWC2::Vsync::Disable; // Fields tracking the current jank event: when it started and how many // janky frames there are. nsecs_t mMissedFrameJankStart = 0; int32_t mMissedFrameJankCount = 0; }; }; } // namespace android } // namespace android