Closed Bug 1048104 Opened 7 years ago Closed 7 years ago

GMPMutexes are not able to be deleted by a GMP and leak

Categories

(Core :: Audio/Video, defect)

29 Branch
x86_64
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla34

People

(Reporter: cpearce, Assigned: cpearce)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

GMPMutex doesn't have a function to allow it to be deleted. So if I run a GMP which creates GMPMutexes with XPCOM_MEM_LEAK_LOG=2 I see geckomediaplugin process leaking mozilla::Mutexes, since GMPMutexImpl uses that to implement itself.

We should either:
1. Keep track of the GMPMutexes created during GMP lifetime, and delete them on GMP process exit, or
2. add a virtual function GMPMutex::Destroy() that GMPs can call to delete the GMPMutex.

I think 2 is best. OpenH264 doesn't use GMPMutex, so it won't technically require a re-spin of the OpenH264 GMP.
Adds GMPMutex::Destroy().

ehugg: This change won't cause any problems for OpenH264 right?
Attachment #8466876 - Flags: review?(rjesup)
Attachment #8466876 - Flags: feedback?(ethanhugg)
Comment on attachment 8466876 [details] [diff] [review]
Patch: Add GMPMutex::Destroy()

Review of attachment 8466876 [details] [diff] [review]:
-----------------------------------------------------------------

r+ given verification of binary compat

::: content/media/gmp/gmp-api/gmp-platform.h
@@ +44,3 @@
>    virtual ~GMPTask() {}
>    virtual void Run() = 0;
> +  virtual void Destroy() = 0; // Deletes object.

Careful... this might impact binary compatibility (vtable order).  Verify before landing this doesn't impact OpenH264

@@ +57,5 @@
>  public:
>    virtual ~GMPMutex() {}
>    virtual void Acquire() = 0;
>    virtual void Release() = 0;
> +  virtual void Destroy() = 0; // Deletes object.

Adding at the end I think is ok, vtable-wise
Attachment #8466876 - Flags: review?(rjesup) → review+
Comment on attachment 8466876 [details] [diff] [review]
Patch: Add GMPMutex::Destroy()

Review of attachment 8466876 [details] [diff] [review]:
-----------------------------------------------------------------

Tested on OSX with OpenH264.  It works fine with restarts and closing/opening tabs as long as we don't change the VTable order on GMPTask.   With Destory() moved to the end OpenH264 does not work, so f+ if you put it back on top.

::: content/media/gmp/gmp-api/gmp-platform.h
@@ +44,3 @@
>    virtual ~GMPTask() {}
>    virtual void Run() = 0;
> +  virtual void Destroy() = 0; // Deletes object.

This does affect OpenH264.  Move it back to the top and it works again.
Attachment #8466876 - Flags: feedback?(ethanhugg) → feedback+
https://hg.mozilla.org/mozilla-central/rev/b7a2e988a666
Assignee: nobody → cpearce
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
You need to log in before you can comment on or make changes to this bug.