已合并
add SetOnRenderProcessDiedCallback client API for render process death notification #30442
add SetOnRenderProcessDiedCallback client API for render process death notification #30442
已合并
LyBbq创建于 6月1日
共 7 个文件变更+34-1
@@ -22,7 +22,7 @@
22 22 
23namespace OHOS {23namespace OHOS {
24namespace Rosen {24namespace Rosen {
25- 25+constexpr uint64_t INVALID_TOKEN_MASK_ID = 0;
26class RSIConnectToRenderProcess : public IRemoteBroker {26class RSIConnectToRenderProcess : public IRemoteBroker {
27public:27public:
28 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.rosen.ConnectToRenderProcess");28 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.rosen.ConnectToRenderProcess");
@@ -26,6 +26,7 @@
26#include <refbase.h>26#include <refbase.h>
27#include <surface_type.h>27#include <surface_type.h>
28#ifndef ROSEN_CROSS_PLATFORM28#ifndef ROSEN_CROSS_PLATFORM
29+#include "platform/ohos/transaction/zidl/rs_iconnect_to_render_process.h"
29#include "platform/ohos/transaction/zidl/rs_iclient_to_render_connection.h"30#include "platform/ohos/transaction/zidl/rs_iclient_to_render_connection.h"
30#include <surface.h>31#include <surface.h>
31#include <utility>32#include <utility>
@@ -221,6 +222,8 @@ public:
221 const FrameStabilityTarget& oldTarget,222 const FrameStabilityTarget& oldTarget,
222 const FrameStabilityTarget& newTarget223 const FrameStabilityTarget& newTarget
223 );224 );
225+ 
226+ void SetOnRenderProcessDiedCallback(const std::function<void()>& callback);
224private:227private:
225 void TriggerSurfaceCaptureCallback(NodeId id, const RSSurfaceCaptureConfig& captureConfig,228 void TriggerSurfaceCaptureCallback(NodeId id, const RSSurfaceCaptureConfig& captureConfig,
226 std::shared_ptr<Media::PixelMap> pixelmap, CaptureError captureErrorCode,229 std::shared_ptr<Media::PixelMap> pixelmap, CaptureError captureErrorCode,
@@ -278,6 +281,7 @@ private:
278#ifndef ROSEN_CROSS_PLATFORM281#ifndef ROSEN_CROSS_PLATFORM
279 sptr<RSIClientToRenderConnection> clientToRenderConnection_;282 sptr<RSIClientToRenderConnection> clientToRenderConnection_;
280 sptr<RSIConnectionToken> token_;283 sptr<RSIConnectionToken> token_;
284+ uint64_t tokenMaskId_ = INVALID_TOKEN_MASK_ID;
281#endif285#endif
282 friend class SurfaceCaptureCallbackDirector;286 friend class SurfaceCaptureCallbackDirector;
283 friend class SurfaceBufferCallbackDirector;287 friend class SurfaceBufferCallbackDirector;
@@ -28,6 +28,10 @@ RSRenderPipelineClient::RSRenderPipelineClient(sptr<IRemoteObject>& connectToRen
28{28{
29}29}
30 30 
31+void RSRenderPipelineClient::SetOnRenderProcessDiedCallback(const std::function<void()>& callback)
32+{
33+}
34+ 
31void RSRenderPipelineClient::CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData)35void RSRenderPipelineClient::CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData)
32{36{
33}37}
@@ -87,6 +87,10 @@ RSRenderPipelineClient::RSRenderPipelineClient(sptr<IRemoteObject>& connectToRen
87 }87 }
88}88}
89 89 
90+void RSRenderPipelineClient::SetOnRenderProcessDiedCallback(const std::function<void()>& callback)
91+{
92+}
93+ 
90void RSRenderPipelineClient::CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData)94void RSRenderPipelineClient::CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData)
91{95{
92 if (clientToRenderConnection_ != nullptr) {96 if (clientToRenderConnection_ != nullptr) {
@@ -28,6 +28,10 @@ RSRenderPipelineClient::RSRenderPipelineClient(sptr<IRemoteObject>& connectToRen
28{28{
29}29}
30 30 
31+void RSRenderPipelineClient::SetOnRenderProcessDiedCallback(const std::function<void()>& callback)
32+{
33+}
34+ 
31void RSRenderPipelineClient::CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData)35void RSRenderPipelineClient::CommitTransaction(std::unique_ptr<RSTransactionData>& transactionData)
32{36{
33}37}
@@ -650,5 +650,14 @@ void RSRenderInterface::SetFreeMultiWindowStatus(bool enable)
650{650{
651 renderPipelineClient_->SetFreeMultiWindowStatus(enable);651 renderPipelineClient_->SetFreeMultiWindowStatus(enable);
652}652}
653+ 
654+void RSRenderInterface::SetOnRenderProcessDiedCallback(const std::function<void()>& callback)
655+{
656+ if (renderPipelineClient_ == nullptr) {
657+ ROSEN_LOGE("RSRenderInterface::SetOnRenderProcessDiedCallback renderPipelineClient_ nullptr");
658+ return;
659+ }
660+ renderPipelineClient_->SetOnRenderProcessDiedCallback(callback);
661+}
653}662}
654}663}
@@ -462,6 +462,14 @@ public:
462 */462 */
463 void SetFreeMultiWindowStatus(bool enable);463 void SetFreeMultiWindowStatus(bool enable);
464 464 
465+ /**
466+ * @brief Set callback for render process died event.
467+ * @param callback Callback function triggered when render process dies.
468+ * @note The callback may be invoked from a different thread. Callers must ensure
469+ * that variables accessed within the callback are thread-safe.
470+ */
471+ void SetOnRenderProcessDiedCallback(const std::function<void()>& callback);
472+ 
465private:473private:
466 RSRenderInterface();474 RSRenderInterface();
467 RSRenderInterface(sptr<IRemoteObject>& connectToRenderRemote);475 RSRenderInterface(sptr<IRemoteObject>& connectToRenderRemote);