From e9d6bcf5e9d63e555b8adaa6bea486e55c8d24d4 Mon Sep 17 00:00:00 2001 From: Littlegnal <8847263+littleGnAl@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:10:37 +0800 Subject: [PATCH] fix: Fix black screen issue in AgoraVideoView caused by incorrect resize handling (#2052) The `resize` value from `OnVideoFrameReceived` became invalid after the recent `iris` refactor(>= 4.3.2). We now manage the resize check internally to prevent black screens in `AgoraVideoView`. --- shared/darwin/TextureRenderer.mm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/shared/darwin/TextureRenderer.mm b/shared/darwin/TextureRenderer.mm index 27b385c87..52de2b031 100644 --- a/shared/darwin/TextureRenderer.mm +++ b/shared/darwin/TextureRenderer.mm @@ -23,7 +23,7 @@ @interface TextureRender () namespace { class RendererDelegate : public agora::iris::VideoFrameObserverDelegate { public: - RendererDelegate(void *renderer) : renderer_(renderer) { } + RendererDelegate(void *renderer) : renderer_(renderer), pre_width_(0), pre_height_(0) { } void OnVideoFrameReceived(const void *videoFrame, const IrisRtcVideoFrameConfig &config, bool resize) override { @@ -36,11 +36,15 @@ void OnVideoFrameReceived(const void *videoFrame, return; } + int tmpWidth = vf->width; + int tmpHeight = vf->height; + bool is_resize = pre_width_ != tmpWidth || pre_height_ != tmpHeight; + pre_width_ = tmpWidth; + pre_height_ = tmpHeight; + CVPixelBufferRef _Nullable pixelBuffer = reinterpret_cast(vf->pixelBuffer); if (pixelBuffer) { - if (resize) { - int tmpWidth = vf->width; - int tmpHeight = vf->height; + if (is_resize) { dispatch_async(dispatch_get_main_queue(), ^{ [renderer.channel invokeMethod:@"onSizeChanged" arguments:@{@"width": @(tmpWidth), @@ -69,6 +73,8 @@ void OnVideoFrameReceived(const void *videoFrame, public: void *renderer_; + int pre_width_; + int pre_height_; }; }