diff options
-rw-r--r-- | libs/binder/RpcState.cpp | 2 | ||||
-rw-r--r-- | libs/binder/include/binder/RpcSession.h | 4 | ||||
-rw-r--r-- | libs/binder/tests/binderRpcWireProtocolTest.cpp | 13 | ||||
-rw-r--r-- | libs/gui/BufferQueueConsumer.cpp | 3 | ||||
-rw-r--r-- | libs/gui/BufferQueueProducer.cpp | 17 | ||||
-rw-r--r-- | opengl/libs/EGL/BlobCache.cpp | 6 | ||||
-rw-r--r-- | opengl/libs/EGL/FileBlobCache.cpp | 7 | ||||
-rw-r--r-- | services/sensorservice/BatteryService.cpp | 4 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp | 13 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/AidlComposerHal.h | 4 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/ComposerHal.h | 4 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp | 4 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HidlComposerHal.h | 4 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.cpp | 61 | ||||
-rw-r--r-- | services/surfaceflinger/SurfaceFlinger.h | 10 | ||||
-rw-r--r-- | services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp | 1 | ||||
-rw-r--r-- | services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h | 1 |
17 files changed, 84 insertions, 74 deletions
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp index ed3ce24e46..03fa69973d 100644 --- a/libs/binder/RpcState.cpp +++ b/libs/binder/RpcState.cpp @@ -928,7 +928,7 @@ processTransactInternalTailCall: transactionData.size() - offsetof(RpcWireTransaction, data)}; Span<const uint32_t> objectTableSpan; - if (session->getProtocolVersion().value() > + if (session->getProtocolVersion().value() >= RPC_WIRE_PROTOCOL_VERSION_RPC_HEADER_FEATURE_EXPLICIT_PARCEL_SIZE) { std::optional<Span<const uint8_t>> objectTableBytes = parcelSpan.splitOff(transaction->parcelDataSize); diff --git a/libs/binder/include/binder/RpcSession.h b/libs/binder/include/binder/RpcSession.h index a323febbc7..cb6460398d 100644 --- a/libs/binder/include/binder/RpcSession.h +++ b/libs/binder/include/binder/RpcSession.h @@ -37,9 +37,9 @@ class RpcState; class RpcTransport; class FdTrigger; -constexpr uint32_t RPC_WIRE_PROTOCOL_VERSION_NEXT = 1; +constexpr uint32_t RPC_WIRE_PROTOCOL_VERSION_NEXT = 2; constexpr uint32_t RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL = 0xF0000000; -constexpr uint32_t RPC_WIRE_PROTOCOL_VERSION = RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL; +constexpr uint32_t RPC_WIRE_PROTOCOL_VERSION = 1; // Starting with this version: // diff --git a/libs/binder/tests/binderRpcWireProtocolTest.cpp b/libs/binder/tests/binderRpcWireProtocolTest.cpp index 3dab2c748b..642cea440d 100644 --- a/libs/binder/tests/binderRpcWireProtocolTest.cpp +++ b/libs/binder/tests/binderRpcWireProtocolTest.cpp @@ -237,14 +237,25 @@ TEST(RpcWire, V0) { checkRepr(kCurrentRepr, 0); } +TEST(RpcWire, V1) { + checkRepr(kCurrentRepr, 1); +} + TEST(RpcWire, CurrentVersion) { checkRepr(kCurrentRepr, RPC_WIRE_PROTOCOL_VERSION); } -static_assert(RPC_WIRE_PROTOCOL_VERSION == RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL, +static_assert(RPC_WIRE_PROTOCOL_VERSION == 1, "If the binder wire protocol is updated, this test should test additional versions. " "The binder wire protocol should only be updated on upstream AOSP."); +TEST(RpcWire, NextIsPlusOneReminder) { + if (RPC_WIRE_PROTOCOL_VERSION != RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL) { + EXPECT_EQ(RPC_WIRE_PROTOCOL_VERSION + 1, RPC_WIRE_PROTOCOL_VERSION_NEXT) + << "Make sure to note what the next version should be."; + } +} + TEST(RpcWire, ReleaseBranchHasFrozenRpcWireProtocol) { if (RPC_WIRE_PROTOCOL_VERSION == RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL) { EXPECT_FALSE(base::GetProperty("ro.build.version.codename", "") == "REL") diff --git a/libs/gui/BufferQueueConsumer.cpp b/libs/gui/BufferQueueConsumer.cpp index 7f7a0437f1..52172090af 100644 --- a/libs/gui/BufferQueueConsumer.cpp +++ b/libs/gui/BufferQueueConsumer.cpp @@ -33,6 +33,7 @@ #include <gui/BufferQueueCore.h> #include <gui/IConsumerListener.h> #include <gui/IProducerListener.h> +#include <gui/TraceUtils.h> #include <private/gui/BufferQueueThreadState.h> #ifndef __ANDROID_VNDK__ @@ -646,7 +647,7 @@ status_t BufferQueueConsumer::setMaxBufferCount(int bufferCount) { status_t BufferQueueConsumer::setMaxAcquiredBufferCount( int maxAcquiredBuffers) { - ATRACE_CALL(); + ATRACE_FORMAT("%s(%d)", __func__, maxAcquiredBuffers); if (maxAcquiredBuffers < 1 || maxAcquiredBuffers > BufferQueueCore::MAX_MAX_ACQUIRED_BUFFERS) { diff --git a/libs/gui/BufferQueueProducer.cpp b/libs/gui/BufferQueueProducer.cpp index 9eb1a9f526..9a2343bffb 100644 --- a/libs/gui/BufferQueueProducer.cpp +++ b/libs/gui/BufferQueueProducer.cpp @@ -35,6 +35,7 @@ #include <gui/GLConsumer.h> #include <gui/IConsumerListener.h> #include <gui/IProducerListener.h> +#include <gui/TraceUtils.h> #include <private/gui/BufferQueueThreadState.h> #include <utils/Log.h> @@ -125,7 +126,7 @@ status_t BufferQueueProducer::setMaxDequeuedBufferCount( status_t BufferQueueProducer::setMaxDequeuedBufferCount(int maxDequeuedBuffers, int* maxBufferCount) { - ATRACE_CALL(); + ATRACE_FORMAT("%s(%d)", __func__, maxDequeuedBuffers); BQ_LOGV("setMaxDequeuedBufferCount: maxDequeuedBuffers = %d", maxDequeuedBuffers); @@ -502,6 +503,20 @@ status_t BufferQueueProducer::dequeueBuffer(int* outSlot, sp<android::Fence>* ou if ((buffer == nullptr) || buffer->needsReallocation(width, height, format, BQ_LAYER_COUNT, usage)) { + if (CC_UNLIKELY(ATRACE_ENABLED())) { + if (buffer == nullptr) { + ATRACE_FORMAT_INSTANT("%s buffer reallocation: null", mConsumerName.string()); + } else { + ATRACE_FORMAT_INSTANT("%s buffer reallocation actual %dx%d format:%d " + "layerCount:%d " + "usage:%d requested: %dx%d format:%d layerCount:%d " + "usage:%d ", + mConsumerName.string(), width, height, format, + BQ_LAYER_COUNT, usage, buffer->getWidth(), + buffer->getHeight(), buffer->getPixelFormat(), + buffer->getLayerCount(), buffer->getUsage()); + } + } mSlots[found].mAcquireCalled = false; mSlots[found].mGraphicBuffer = nullptr; mSlots[found].mRequestBufferCalled = false; diff --git a/opengl/libs/EGL/BlobCache.cpp b/opengl/libs/EGL/BlobCache.cpp index aecfc6b077..b3a4bc19fd 100644 --- a/opengl/libs/EGL/BlobCache.cpp +++ b/opengl/libs/EGL/BlobCache.cpp @@ -15,6 +15,7 @@ */ //#define LOG_NDEBUG 0 +#define ATRACE_TAG ATRACE_TAG_GRAPHICS #include "BlobCache.h" @@ -22,6 +23,7 @@ #include <errno.h> #include <inttypes.h> #include <log/log.h> +#include <utils/Trace.h> #include <chrono> @@ -230,6 +232,8 @@ int BlobCache::flatten(void* buffer, size_t size) const { } int BlobCache::unflatten(void const* buffer, size_t size) { + ATRACE_NAME("BlobCache::unflatten"); + // All errors should result in the BlobCache being in an empty state. clear(); @@ -293,6 +297,8 @@ long int BlobCache::blob_random() { } void BlobCache::clean() { + ATRACE_NAME("BlobCache::clean"); + // Remove a random cache entry until the total cache size gets below half // the maximum total cache size. while (mTotalSize > mMaxTotalSize / 2) { diff --git a/opengl/libs/EGL/FileBlobCache.cpp b/opengl/libs/EGL/FileBlobCache.cpp index 1026842f87..4a0fac4ce5 100644 --- a/opengl/libs/EGL/FileBlobCache.cpp +++ b/opengl/libs/EGL/FileBlobCache.cpp @@ -14,6 +14,8 @@ ** limitations under the License. */ +#define ATRACE_TAG ATRACE_TAG_GRAPHICS + #include "FileBlobCache.h" #include <errno.h> @@ -24,6 +26,7 @@ #include <unistd.h> #include <log/log.h> +#include <utils/Trace.h> // Cache file header static const char* cacheFileMagic = "EGL$"; @@ -51,6 +54,8 @@ FileBlobCache::FileBlobCache(size_t maxKeySize, size_t maxValueSize, size_t maxT const std::string& filename) : BlobCache(maxKeySize, maxValueSize, maxTotalSize) , mFilename(filename) { + ATRACE_CALL(); + if (mFilename.length() > 0) { size_t headerSize = cacheFileHeaderSize; @@ -117,6 +122,8 @@ FileBlobCache::FileBlobCache(size_t maxKeySize, size_t maxValueSize, size_t maxT } void FileBlobCache::writeToFile() { + ATRACE_CALL(); + if (mFilename.length() > 0) { size_t cacheSize = getFlattenedSize(); size_t headerSize = cacheFileHeaderSize; diff --git a/services/sensorservice/BatteryService.cpp b/services/sensorservice/BatteryService.cpp index b0fbe5dc4e..0ea548c958 100644 --- a/services/sensorservice/BatteryService.cpp +++ b/services/sensorservice/BatteryService.cpp @@ -30,8 +30,8 @@ namespace android { // --------------------------------------------------------------------------- -BatteryService::BatteryService() : mBatteryStatService(nullptr) { -} +BatteryService::BatteryService() + : mBatteryStatService(nullptr), mLastWakeupSensorEventReportedMs(0) {} bool BatteryService::addSensor(uid_t uid, int handle) { Mutex::Autolock _l(mActivationsLock); diff --git a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp index f28bfd44cd..f7049b98e7 100644 --- a/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp +++ b/services/surfaceflinger/DisplayHardware/AidlComposerHal.cpp @@ -329,14 +329,6 @@ void AidlComposer::registerCallback(HWC2::ComposerCallback& callback) { } } -void AidlComposer::resetCommands(Display display) { - mMutex.lock_shared(); - if (auto writer = getWriter(display)) { - writer->get().reset(); - } - mMutex.unlock_shared(); -} - Error AidlComposer::executeCommands(Display display) { mMutex.lock_shared(); auto error = execute(display); @@ -1054,9 +1046,8 @@ Error AidlComposer::execute(Display display) { return Error::BAD_DISPLAY; } - const auto& commands = writer->get().getPendingCommands(); + auto commands = writer->get().takePendingCommands(); if (commands.empty()) { - writer->get().reset(); return Error::NONE; } @@ -1088,8 +1079,6 @@ Error AidlComposer::execute(Display display) { } } - writer->get().reset(); - return error; } diff --git a/services/surfaceflinger/DisplayHardware/AidlComposerHal.h b/services/surfaceflinger/DisplayHardware/AidlComposerHal.h index 8313c09e58..ce05b382cc 100644 --- a/services/surfaceflinger/DisplayHardware/AidlComposerHal.h +++ b/services/surfaceflinger/DisplayHardware/AidlComposerHal.h @@ -72,10 +72,6 @@ public: void registerCallback(HWC2::ComposerCallback& callback) override; - // Reset all pending commands in the command buffer. Useful if you want to - // skip a frame but have already queued some commands. - void resetCommands(Display) override; - // Explicitly flush all pending commands in the command buffer. Error executeCommands(Display) override; diff --git a/services/surfaceflinger/DisplayHardware/ComposerHal.h b/services/surfaceflinger/DisplayHardware/ComposerHal.h index c65c572920..cf677955bf 100644 --- a/services/surfaceflinger/DisplayHardware/ComposerHal.h +++ b/services/surfaceflinger/DisplayHardware/ComposerHal.h @@ -110,10 +110,6 @@ public: virtual void registerCallback(HWC2::ComposerCallback& callback) = 0; - // Reset all pending commands in the command buffer. Useful if you want to - // skip a frame but have already queued some commands. - virtual void resetCommands(Display) = 0; - // Explicitly flush all pending commands in the command buffer. virtual Error executeCommands(Display) = 0; diff --git a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp index 23de4fa42e..e0f6c45f70 100644 --- a/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp +++ b/services/surfaceflinger/DisplayHardware/HidlComposerHal.cpp @@ -293,10 +293,6 @@ void HidlComposer::registerCallback(const sp<IComposerCallback>& callback) { } } -void HidlComposer::resetCommands(Display) { - mWriter.reset(); -} - Error HidlComposer::executeCommands(Display) { return execute(); } diff --git a/services/surfaceflinger/DisplayHardware/HidlComposerHal.h b/services/surfaceflinger/DisplayHardware/HidlComposerHal.h index d04652bf21..0521acf9c4 100644 --- a/services/surfaceflinger/DisplayHardware/HidlComposerHal.h +++ b/services/surfaceflinger/DisplayHardware/HidlComposerHal.h @@ -174,10 +174,6 @@ public: void registerCallback(HWC2::ComposerCallback& callback) override; - // Reset all pending commands in the command buffer. Useful if you want to - // skip a frame but have already queued some commands. - void resetCommands(Display) override; - // Explicitly flush all pending commands in the command buffer. Error executeCommands(Display) override; diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index 48b41448a1..c88bff5ed8 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2146,7 +2146,14 @@ void SurfaceFlinger::setVsyncEnabled(PhysicalDisplayId id, bool enabled) { })); } -auto SurfaceFlinger::getPreviousPresentFence(TimePoint frameTime, Period vsyncPeriod) +bool SurfaceFlinger::wouldPresentEarly(TimePoint frameTime, Period vsyncPeriod) const { + const bool isThreeVsyncsAhead = mExpectedPresentTime - frameTime > 2 * vsyncPeriod; + return isThreeVsyncsAhead || + getPreviousPresentFence(frameTime, vsyncPeriod)->getSignalTime() != + Fence::SIGNAL_TIME_PENDING; +} + +auto SurfaceFlinger::getPreviousPresentFence(TimePoint frameTime, Period vsyncPeriod) const -> const FenceTimePtr& { const bool isTwoVsyncsAhead = mExpectedPresentTime - frameTime > vsyncPeriod; const size_t i = static_cast<size_t>(isTwoVsyncsAhead); @@ -2614,21 +2621,14 @@ void SurfaceFlinger::composite(TimePoint frameTime, VsyncId vsyncId) refreshArgs.devOptFlashDirtyRegionsDelay = std::chrono::milliseconds(mDebugFlashDelay); } - const auto prevVsyncTime = mExpectedPresentTime - mScheduler->getVsyncSchedule()->period(); - const auto hwcMinWorkDuration = mVsyncConfiguration->getCurrentConfigs().hwcMinWorkDuration; - const Period vsyncPeriod = mScheduler->getVsyncSchedule()->period(); - const bool threeVsyncsAhead = mExpectedPresentTime - frameTime > 2 * vsyncPeriod; - // We should wait for the earliest present time if HWC doesn't support ExpectedPresentTime, - // and the next vsync is not already taken by the previous frame. - const bool waitForEarliestPresent = - !getHwComposer().getComposer()->isSupported( - Hwc2::Composer::OptionalFeature::ExpectedPresentTime) && - (threeVsyncsAhead || - mPreviousPresentFences[0].fenceTime->getSignalTime() != Fence::SIGNAL_TIME_PENDING); + if (!getHwComposer().getComposer()->isSupported( + Hwc2::Composer::OptionalFeature::ExpectedPresentTime) && + wouldPresentEarly(frameTime, vsyncPeriod)) { + const auto prevVsyncTime = mExpectedPresentTime - vsyncPeriod; + const auto hwcMinWorkDuration = mVsyncConfiguration->getCurrentConfigs().hwcMinWorkDuration; - if (waitForEarliestPresent) { refreshArgs.earliestPresentTime = prevVsyncTime - hwcMinWorkDuration; } @@ -2662,9 +2662,10 @@ void SurfaceFlinger::composite(TimePoint frameTime, VsyncId vsyncId) // Send a power hint hint after presentation is finished if (mPowerHintSessionEnabled) { - mPowerAdvisor->setSfPresentTiming(TimePoint::fromNs(mPreviousPresentFences[0] - .fenceTime->getSignalTime()), - TimePoint::now()); + const nsecs_t pastPresentTime = + getPreviousPresentFence(frameTime, vsyncPeriod)->getSignalTime(); + + mPowerAdvisor->setSfPresentTiming(TimePoint::fromNs(pastPresentTime), TimePoint::now()); mPowerAdvisor->reportActualWorkDuration(); } @@ -3718,10 +3719,10 @@ void SurfaceFlinger::commitTransactionsLocked(uint32_t transactionFlags) { } void SurfaceFlinger::updateInputFlinger() { - ATRACE_CALL(); - if (!mInputFlinger) { + if (!mInputFlinger || (!mUpdateInputInfo && mInputWindowCommands.empty())) { return; } + ATRACE_CALL(); std::vector<WindowInfo> windowInfos; std::vector<DisplayInfo> displayInfos; @@ -3730,20 +3731,18 @@ void SurfaceFlinger::updateInputFlinger() { mUpdateInputInfo = false; updateWindowInfo = true; buildWindowInfos(windowInfos, displayInfos); - } else if (mInputWindowCommands.empty()) { - return; } - std::unordered_set<Layer*> visibleLayers; - mDrawingState.traverse([&visibleLayers](Layer* layer) { - if (layer->isVisibleForInput()) { - visibleLayers.insert(layer); + std::unordered_set<int32_t> visibleWindowIds; + for (WindowInfo& windowInfo : windowInfos) { + if (!windowInfo.inputConfig.test(WindowInfo::InputConfig::NOT_VISIBLE)) { + visibleWindowIds.insert(windowInfo.id); } - }); - bool visibleLayersChanged = false; - if (visibleLayers != mVisibleLayers) { - visibleLayersChanged = true; - mVisibleLayers = std::move(visibleLayers); + } + bool visibleWindowsChanged = false; + if (visibleWindowIds != mVisibleWindowIds) { + visibleWindowsChanged = true; + mVisibleWindowIds = std::move(visibleWindowIds); } BackgroundExecutor::getInstance().sendCallbacks({[updateWindowInfo, @@ -3752,14 +3751,14 @@ void SurfaceFlinger::updateInputFlinger() { inputWindowCommands = std::move(mInputWindowCommands), inputFlinger = mInputFlinger, this, - visibleLayersChanged]() { + visibleWindowsChanged]() { ATRACE_NAME("BackgroundExecutor::updateInputFlinger"); if (updateWindowInfo) { mWindowInfosListenerInvoker ->windowInfosChanged(std::move(windowInfos), std::move(displayInfos), std::move( inputWindowCommands.windowInfosReportedListeners), - /* forceImmediateCall= */ visibleLayersChanged || + /* forceImmediateCall= */ visibleWindowsChanged || !inputWindowCommands.focusRequests.empty()); } else { // If there are listeners but no changes to input windows, call the listeners diff --git a/services/surfaceflinger/SurfaceFlinger.h b/services/surfaceflinger/SurfaceFlinger.h index fffd63a515..cd7659bc0b 100644 --- a/services/surfaceflinger/SurfaceFlinger.h +++ b/services/surfaceflinger/SurfaceFlinger.h @@ -998,7 +998,9 @@ private: using FenceTimePtr = std::shared_ptr<FenceTime>; - const FenceTimePtr& getPreviousPresentFence(TimePoint frameTime, Period) + bool wouldPresentEarly(TimePoint frameTime, Period) const REQUIRES(kMainThreadContext); + + const FenceTimePtr& getPreviousPresentFence(TimePoint frameTime, Period) const REQUIRES(kMainThreadContext); // Blocks the thread waiting for up to graceTimeMs in case the fence is about to signal. @@ -1428,10 +1430,8 @@ private: display::DisplayMap<ui::LayerStack, frontend::DisplayInfo> mFrontEndDisplayInfos; bool mFrontEndDisplayInfosChanged = false; - // Layers visible during the last commit. This set should only be used for testing set equality - // and membership. The pointers should not be dereferenced as it's possible the set contains - // pointers to freed layers. - std::unordered_set<Layer*> mVisibleLayers; + // WindowInfo ids visible during the last commit. + std::unordered_set<int32_t> mVisibleWindowIds; }; class SurfaceComposerAIDL : public gui::BnSurfaceComposer { diff --git a/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp b/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp index a9247fe903..9fac14ed4c 100644 --- a/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp +++ b/services/surfaceflinger/fuzzer/surfaceflinger_displayhardware_fuzzer.cpp @@ -327,7 +327,6 @@ void DisplayHardwareFuzzer::invokeAidlComposer() { invokeComposerHal2_4(&composer, display, outLayer); composer.executeCommands(display); - composer.resetCommands(display); composer.destroyLayer(display, outLayer); composer.destroyVirtualDisplay(display); diff --git a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h index 5dc3490eb8..d3fb9fc3f8 100644 --- a/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h +++ b/services/surfaceflinger/tests/unittests/mock/DisplayHardware/MockComposer.h @@ -55,7 +55,6 @@ public: std::vector<aidl::android::hardware::graphics::composer3::Capability>()); MOCK_METHOD0(dumpDebugInfo, std::string()); MOCK_METHOD1(registerCallback, void(HWC2::ComposerCallback&)); - MOCK_METHOD1(resetCommands, void(Display)); MOCK_METHOD1(executeCommands, Error(Display)); MOCK_METHOD0(getMaxVirtualDisplayCount, uint32_t()); MOCK_METHOD4(createVirtualDisplay, Error(uint32_t, uint32_t, PixelFormat*, Display*)); |