Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When i dispose videorender, it crashed #77

Closed
nikohpng opened this issue Apr 18, 2023 · 1 comment
Closed

When i dispose videorender, it crashed #77

nikohpng opened this issue Apr 18, 2023 · 1 comment

Comments

@nikohpng
Copy link
Contributor

nikohpng commented Apr 18, 2023

Description

One videorender leaveed When I work under high loads.
then the videorender will be disposed.
when it is disposing, the app crashed.
I find that _mtx_destroy_in_situ was called.

Log

2f823af38e3348aacf94463c32c3577

ViewPoint

I think there is a risk of being disposed of while rendering is being called. such like this

const FlutterDesktopPixelBuffer* FlutterVideoRenderer::CopyPixelBuffer(
    size_t width,
    size_t height) const {
  mutex_.lock();
  if (pixel_buffer_.get() && frame_.get()) {
    if (pixel_buffer_->width != frame_->width() ||
        pixel_buffer_->height != frame_->height()) {
      size_t buffer_size =
          (size_t(frame_->width()) * size_t(frame_->height())) * (32 >> 3);
      rgb_buffer_.reset(new uint8_t[buffer_size]);
      pixel_buffer_->width = frame_->width();
      pixel_buffer_->height = frame_->height();
    }

    frame_->ConvertToARGB(RTCVideoFrame::Type::kABGR, rgb_buffer_.get(), 0,
                          (int)pixel_buffer_->width,
                          (int)pixel_buffer_->height);

    pixel_buffer_->buffer = rgb_buffer_.get();
    mutex_.unlock();
    return pixel_buffer_.get();
  }
  mutex_.unlock();
  return nullptr;
}
void FlutterVideoRenderer::OnFrame(scoped_refptr<RTCVideoFrame> frame) {
mutex_.lock();
frame_ = frame;
// haven't do this
// mutex_.unlock();
}
//sametime
void FlutterVideoRendererManager::VideoRendererDispose(
    int64_t texture_id,
    std::unique_ptr<MethodResultProxy> result) {
  auto it = renderers_.find(texture_id);
  if (it != renderers_.end()) {
    base_->textures_->UnregisterTexture(texture_id);
    renderers_.erase(it);
    result->Success();
    return;
  }
  result->Error("VideoRendererDisposeFailed",
                "VideoRendererDispose() texture not found!");
}

because of asynchronous, when mutex_.lock(),we immediately call renderers_.erase(it). Then it will crash

@nikohpng
Copy link
Contributor Author

I have solved. This issue shouldn't be here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant