Loading libs/binder/BpBinder.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -388,7 +388,8 @@ status_t BpBinder::linkToDeath( { if (isRpcBinder()) { if (rpcSession()->getMaxIncomingThreads() < 1) { ALOGE("Cannot register a DeathRecipient without any incoming connections."); ALOGE("Cannot register a DeathRecipient without any incoming threads. Need to set max " "incoming threads to a value greater than 0 before calling linkToDeath."); return INVALID_OPERATION; } } else if constexpr (!kEnableKernelIpc) { Loading libs/gui/ITransactionCompletedListener.cpp +18 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,12 @@ enum class Tag : uint32_t { } // Anonymous namespace namespace { // Anonymous constexpr int32_t kSerializedCallbackTypeOnCompelteWithJankData = 2; } // Anonymous namespace status_t FrameEventHistoryStats::writeToParcel(Parcel* output) const { status_t err = output->writeUint64(frameNumber); if (err != NO_ERROR) return err; Loading Loading @@ -349,7 +355,11 @@ ListenerCallbacks ListenerCallbacks::filter(CallbackId::Type type) const { status_t CallbackId::writeToParcel(Parcel* output) const { SAFE_PARCEL(output->writeInt64, id); if (type == Type::ON_COMPLETE && includeJankData) { SAFE_PARCEL(output->writeInt32, kSerializedCallbackTypeOnCompelteWithJankData); } else { SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(type)); } return NO_ERROR; } Loading @@ -357,7 +367,13 @@ status_t CallbackId::readFromParcel(const Parcel* input) { SAFE_PARCEL(input->readInt64, &id); int32_t typeAsInt; SAFE_PARCEL(input->readInt32, &typeAsInt); if (typeAsInt == kSerializedCallbackTypeOnCompelteWithJankData) { type = Type::ON_COMPLETE; includeJankData = true; } else { type = static_cast<CallbackId::Type>(typeAsInt); includeJankData = false; } return NO_ERROR; } Loading libs/gui/LayerState.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -684,6 +684,9 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eDimmingEnabledChanged; dimmingEnabled = other.dimmingEnabled; } if (other.what & eFlushJankData) { what |= eFlushJankData; } if ((other.what & what) != other.what) { ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " "other.what=0x%" PRIX64 " what=0x%" PRIX64 " unmerged flags=0x%" PRIX64, Loading libs/gui/SurfaceComposerClient.cpp +44 −7 Original line number Diff line number Diff line Loading @@ -82,6 +82,8 @@ std::atomic<uint32_t> idCounter = 0; int64_t generateId() { return (((int64_t)getpid()) << 32) | ++idCounter; } void emptyCallback(nsecs_t, const sp<Fence>&, const std::vector<SurfaceControlStats>&) {} } // namespace ComposerService::ComposerService() Loading Loading @@ -249,6 +251,14 @@ CallbackId TransactionCompletedListener::addCallbackFunction( surfaceControls, CallbackId::Type callbackType) { std::lock_guard<std::mutex> lock(mMutex); return addCallbackFunctionLocked(callbackFunction, surfaceControls, callbackType); } CallbackId TransactionCompletedListener::addCallbackFunctionLocked( const TransactionCompletedCallback& callbackFunction, const std::unordered_set<sp<SurfaceControl>, SurfaceComposerClient::SCHash>& surfaceControls, CallbackId::Type callbackType) { startListeningLocked(); CallbackId callbackId(getNextIdLocked(), callbackType); Loading @@ -257,6 +267,11 @@ CallbackId TransactionCompletedListener::addCallbackFunction( for (const auto& surfaceControl : surfaceControls) { callbackSurfaceControls[surfaceControl->getHandle()] = surfaceControl; if (callbackType == CallbackId::Type::ON_COMPLETE && mJankListeners.count(surfaceControl->getLayerId()) != 0) { callbackId.includeJankData = true; } } return callbackId; Loading Loading @@ -305,15 +320,26 @@ void TransactionCompletedListener::removeSurfaceStatsListener(void* context, voi } void TransactionCompletedListener::addSurfaceControlToCallbacks( const sp<SurfaceControl>& surfaceControl, const std::unordered_set<CallbackId, CallbackIdHash>& callbackIds) { SurfaceComposerClient::CallbackInfo& callbackInfo, const sp<SurfaceControl>& surfaceControl) { std::lock_guard<std::mutex> lock(mMutex); for (auto callbackId : callbackIds) { bool includingJankData = false; for (auto callbackId : callbackInfo.callbackIds) { mCallbacks[callbackId].surfaceControls.emplace(std::piecewise_construct, std::forward_as_tuple( surfaceControl->getHandle()), std::forward_as_tuple(surfaceControl)); includingJankData = includingJankData || callbackId.includeJankData; } // If no registered callback is requesting jank data, but there is a jank listener registered // on the new surface control, add a synthetic callback that requests the jank data. if (!includingJankData && mJankListeners.count(surfaceControl->getLayerId()) != 0) { CallbackId callbackId = addCallbackFunctionLocked(&emptyCallback, callbackInfo.surfaceControls, CallbackId::Type::ON_COMPLETE); callbackInfo.callbackIds.emplace(callbackId); } } Loading Loading @@ -930,8 +956,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr // register all surface controls for all callbackIds for this listener that is merging for (const auto& surfaceControl : currentProcessCallbackInfo.surfaceControls) { TransactionCompletedListener::getInstance() ->addSurfaceControlToCallbacks(surfaceControl, currentProcessCallbackInfo.callbackIds); ->addSurfaceControlToCallbacks(currentProcessCallbackInfo, surfaceControl); } } Loading Loading @@ -1181,6 +1206,19 @@ sp<IBinder> SurfaceComposerClient::Transaction::getDefaultApplyToken() { void SurfaceComposerClient::Transaction::setDefaultApplyToken(sp<IBinder> applyToken) { sApplyToken = applyToken; } status_t SurfaceComposerClient::Transaction::sendSurfaceFlushJankDataTransaction( const sp<SurfaceControl>& sc) { Transaction t; layer_state_t* s = t.getLayerState(sc); if (!s) { return BAD_INDEX; } s->what |= layer_state_t::eFlushJankData; t.registerSurfaceControlForCallback(sc); return t.apply(/*sync=*/false, /* oneWay=*/true); } // --------------------------------------------------------------------------- sp<IBinder> SurfaceComposerClient::createDisplay(const String8& displayName, bool secure, Loading Loading @@ -1254,8 +1292,7 @@ void SurfaceComposerClient::Transaction::registerSurfaceControlForCallback( auto& callbackInfo = mListenerCallbacks[TransactionCompletedListener::getIInstance()]; callbackInfo.surfaceControls.insert(sc); TransactionCompletedListener::getInstance() ->addSurfaceControlToCallbacks(sc, callbackInfo.callbackIds); TransactionCompletedListener::getInstance()->addSurfaceControlToCallbacks(callbackInfo, sc); } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setPosition( Loading libs/gui/include/gui/ITransactionCompletedListener.h +7 −2 Original line number Diff line number Diff line Loading @@ -40,10 +40,15 @@ class ListenerCallbacks; class CallbackId : public Parcelable { public: int64_t id; enum class Type : int32_t { ON_COMPLETE, ON_COMMIT } type; enum class Type : int32_t { ON_COMPLETE = 0, ON_COMMIT = 1, /*reserved for serialization = 2*/ } type; bool includeJankData; // Only respected for ON_COMPLETE callbacks. CallbackId() {} CallbackId(int64_t id, Type type) : id(id), type(type) {} CallbackId(int64_t id, Type type) : id(id), type(type), includeJankData(false) {} status_t writeToParcel(Parcel* output) const override; status_t readFromParcel(const Parcel* input) override; Loading Loading
libs/binder/BpBinder.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -388,7 +388,8 @@ status_t BpBinder::linkToDeath( { if (isRpcBinder()) { if (rpcSession()->getMaxIncomingThreads() < 1) { ALOGE("Cannot register a DeathRecipient without any incoming connections."); ALOGE("Cannot register a DeathRecipient without any incoming threads. Need to set max " "incoming threads to a value greater than 0 before calling linkToDeath."); return INVALID_OPERATION; } } else if constexpr (!kEnableKernelIpc) { Loading
libs/gui/ITransactionCompletedListener.cpp +18 −2 Original line number Diff line number Diff line Loading @@ -39,6 +39,12 @@ enum class Tag : uint32_t { } // Anonymous namespace namespace { // Anonymous constexpr int32_t kSerializedCallbackTypeOnCompelteWithJankData = 2; } // Anonymous namespace status_t FrameEventHistoryStats::writeToParcel(Parcel* output) const { status_t err = output->writeUint64(frameNumber); if (err != NO_ERROR) return err; Loading Loading @@ -349,7 +355,11 @@ ListenerCallbacks ListenerCallbacks::filter(CallbackId::Type type) const { status_t CallbackId::writeToParcel(Parcel* output) const { SAFE_PARCEL(output->writeInt64, id); if (type == Type::ON_COMPLETE && includeJankData) { SAFE_PARCEL(output->writeInt32, kSerializedCallbackTypeOnCompelteWithJankData); } else { SAFE_PARCEL(output->writeInt32, static_cast<int32_t>(type)); } return NO_ERROR; } Loading @@ -357,7 +367,13 @@ status_t CallbackId::readFromParcel(const Parcel* input) { SAFE_PARCEL(input->readInt64, &id); int32_t typeAsInt; SAFE_PARCEL(input->readInt32, &typeAsInt); if (typeAsInt == kSerializedCallbackTypeOnCompelteWithJankData) { type = Type::ON_COMPLETE; includeJankData = true; } else { type = static_cast<CallbackId::Type>(typeAsInt); includeJankData = false; } return NO_ERROR; } Loading
libs/gui/LayerState.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -684,6 +684,9 @@ void layer_state_t::merge(const layer_state_t& other) { what |= eDimmingEnabledChanged; dimmingEnabled = other.dimmingEnabled; } if (other.what & eFlushJankData) { what |= eFlushJankData; } if ((other.what & what) != other.what) { ALOGE("Unmerged SurfaceComposer Transaction properties. LayerState::merge needs updating? " "other.what=0x%" PRIX64 " what=0x%" PRIX64 " unmerged flags=0x%" PRIX64, Loading
libs/gui/SurfaceComposerClient.cpp +44 −7 Original line number Diff line number Diff line Loading @@ -82,6 +82,8 @@ std::atomic<uint32_t> idCounter = 0; int64_t generateId() { return (((int64_t)getpid()) << 32) | ++idCounter; } void emptyCallback(nsecs_t, const sp<Fence>&, const std::vector<SurfaceControlStats>&) {} } // namespace ComposerService::ComposerService() Loading Loading @@ -249,6 +251,14 @@ CallbackId TransactionCompletedListener::addCallbackFunction( surfaceControls, CallbackId::Type callbackType) { std::lock_guard<std::mutex> lock(mMutex); return addCallbackFunctionLocked(callbackFunction, surfaceControls, callbackType); } CallbackId TransactionCompletedListener::addCallbackFunctionLocked( const TransactionCompletedCallback& callbackFunction, const std::unordered_set<sp<SurfaceControl>, SurfaceComposerClient::SCHash>& surfaceControls, CallbackId::Type callbackType) { startListeningLocked(); CallbackId callbackId(getNextIdLocked(), callbackType); Loading @@ -257,6 +267,11 @@ CallbackId TransactionCompletedListener::addCallbackFunction( for (const auto& surfaceControl : surfaceControls) { callbackSurfaceControls[surfaceControl->getHandle()] = surfaceControl; if (callbackType == CallbackId::Type::ON_COMPLETE && mJankListeners.count(surfaceControl->getLayerId()) != 0) { callbackId.includeJankData = true; } } return callbackId; Loading Loading @@ -305,15 +320,26 @@ void TransactionCompletedListener::removeSurfaceStatsListener(void* context, voi } void TransactionCompletedListener::addSurfaceControlToCallbacks( const sp<SurfaceControl>& surfaceControl, const std::unordered_set<CallbackId, CallbackIdHash>& callbackIds) { SurfaceComposerClient::CallbackInfo& callbackInfo, const sp<SurfaceControl>& surfaceControl) { std::lock_guard<std::mutex> lock(mMutex); for (auto callbackId : callbackIds) { bool includingJankData = false; for (auto callbackId : callbackInfo.callbackIds) { mCallbacks[callbackId].surfaceControls.emplace(std::piecewise_construct, std::forward_as_tuple( surfaceControl->getHandle()), std::forward_as_tuple(surfaceControl)); includingJankData = includingJankData || callbackId.includeJankData; } // If no registered callback is requesting jank data, but there is a jank listener registered // on the new surface control, add a synthetic callback that requests the jank data. if (!includingJankData && mJankListeners.count(surfaceControl->getLayerId()) != 0) { CallbackId callbackId = addCallbackFunctionLocked(&emptyCallback, callbackInfo.surfaceControls, CallbackId::Type::ON_COMPLETE); callbackInfo.callbackIds.emplace(callbackId); } } Loading Loading @@ -930,8 +956,7 @@ SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::merge(Tr // register all surface controls for all callbackIds for this listener that is merging for (const auto& surfaceControl : currentProcessCallbackInfo.surfaceControls) { TransactionCompletedListener::getInstance() ->addSurfaceControlToCallbacks(surfaceControl, currentProcessCallbackInfo.callbackIds); ->addSurfaceControlToCallbacks(currentProcessCallbackInfo, surfaceControl); } } Loading Loading @@ -1181,6 +1206,19 @@ sp<IBinder> SurfaceComposerClient::Transaction::getDefaultApplyToken() { void SurfaceComposerClient::Transaction::setDefaultApplyToken(sp<IBinder> applyToken) { sApplyToken = applyToken; } status_t SurfaceComposerClient::Transaction::sendSurfaceFlushJankDataTransaction( const sp<SurfaceControl>& sc) { Transaction t; layer_state_t* s = t.getLayerState(sc); if (!s) { return BAD_INDEX; } s->what |= layer_state_t::eFlushJankData; t.registerSurfaceControlForCallback(sc); return t.apply(/*sync=*/false, /* oneWay=*/true); } // --------------------------------------------------------------------------- sp<IBinder> SurfaceComposerClient::createDisplay(const String8& displayName, bool secure, Loading Loading @@ -1254,8 +1292,7 @@ void SurfaceComposerClient::Transaction::registerSurfaceControlForCallback( auto& callbackInfo = mListenerCallbacks[TransactionCompletedListener::getIInstance()]; callbackInfo.surfaceControls.insert(sc); TransactionCompletedListener::getInstance() ->addSurfaceControlToCallbacks(sc, callbackInfo.callbackIds); TransactionCompletedListener::getInstance()->addSurfaceControlToCallbacks(callbackInfo, sc); } SurfaceComposerClient::Transaction& SurfaceComposerClient::Transaction::setPosition( Loading
libs/gui/include/gui/ITransactionCompletedListener.h +7 −2 Original line number Diff line number Diff line Loading @@ -40,10 +40,15 @@ class ListenerCallbacks; class CallbackId : public Parcelable { public: int64_t id; enum class Type : int32_t { ON_COMPLETE, ON_COMMIT } type; enum class Type : int32_t { ON_COMPLETE = 0, ON_COMMIT = 1, /*reserved for serialization = 2*/ } type; bool includeJankData; // Only respected for ON_COMPLETE callbacks. CallbackId() {} CallbackId(int64_t id, Type type) : id(id), type(type) {} CallbackId(int64_t id, Type type) : id(id), type(type), includeJankData(false) {} status_t writeToParcel(Parcel* output) const override; status_t readFromParcel(const Parcel* input) override; Loading