Commit c1dee1eb authored by Andrew Osmond's avatar Andrew Osmond
Browse files

Bug 1831099 - Remove lock requirement for...

Bug 1831099 - Remove lock requirement for ImageContainer::mNotifyCompositeListener to avoid deadlock. r=jnicol

In bug 1827024 we added a lock to protect mNotifyCompositeListener but
this turned out to be overzealous and unnecessary as we currently only
ever access the member on the ImageBridge thread. We can just assert
instead to ensure we don't regress on this. Removing the lock
requirement solves a deadlock.

Differential Revision: https://phabricator.services.mozilla.com/D177033
parent c3884848
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -236,6 +236,12 @@ Maybe<SurfaceDescriptor> Image::GetDescFromTexClient(
  return Some(ret);
}

already_AddRefed<ImageContainerListener>
ImageContainer::GetImageContainerListener() const {
  MOZ_ASSERT(InImageBridgeChildThread());
  return do_AddRef(mNotifyCompositeListener);
}

RefPtr<PlanarYCbCrImage> ImageContainer::CreatePlanarYCbCrImage() {
  RecursiveMutexAutoLock lock(mRecursiveMutex);
  EnsureImageClient();
+6 −8
Original line number Diff line number Diff line
@@ -361,9 +361,11 @@ class ImageContainer final : public SupportsThreadSafeWeakPtr<ImageContainer> {
  void SetCurrentImages(const nsTArray<NonOwningImage>& aImages);

  /**
   * Clear all images. Let ImageClient release all TextureClients.
   * Clear all images. Let ImageClient release all TextureClients. Because we
   * may release the lock after acquiring it in this method, it cannot be called
   * with the lock held.
   */
  void ClearAllImages();
  void ClearAllImages() MOZ_EXCLUDES(mRecursiveMutex);

  /**
   * Clear any resources that are not immediately necessary. This may be called
@@ -544,10 +546,7 @@ class ImageContainer final : public SupportsThreadSafeWeakPtr<ImageContainer> {
  void NotifyComposite(const ImageCompositeNotification& aNotification);
  void NotifyDropped(uint32_t aDropped);

  already_AddRefed<ImageContainerListener> GetImageContainerListener() {
    RecursiveMutexAutoLock lock(mRecursiveMutex);
    return do_AddRef(mNotifyCompositeListener);
  }
  already_AddRefed<ImageContainerListener> GetImageContainerListener() const;

  /**
   * Get the ImageClient associated with this container. Returns only after
@@ -645,8 +644,7 @@ class ImageContainer final : public SupportsThreadSafeWeakPtr<ImageContainer> {
  // ProducerID for last current image(s)
  ProducerID mCurrentProducerID MOZ_GUARDED_BY(mRecursiveMutex);

  RefPtr<ImageContainerListener> mNotifyCompositeListener
      MOZ_GUARDED_BY(mRecursiveMutex);
  RefPtr<ImageContainerListener> mNotifyCompositeListener;

  static mozilla::Atomic<uint32_t> sGenerationCounter;
};