Skip to content

Conversation

@marcin-mielczarczyk-red
Copy link

@marcin-mielczarczyk-red marcin-mielczarczyk-red commented Nov 13, 2025

When HTMLMediaElement has been created in WPE and HTMLMediaElement::setMediaKeys() method was called to set DRM keys, CDMThunder implementation already allocates CDM resources and they're not released until HTMLMediaElement object is destructed.
HTMLMediaElement destruction is non-deterministic and it's relying on Garbage Collector.
In this case very often we observe that after WPE exit (WPE process is not closed, but some #boot address is being loaded), CDM resources are not released immediately and CDM can't be used by other applications like IP Player or Netflix.

Proposed solution introduces following changes:

  1. CDMPrivateThunder implementation doesn't occupy CDM resources permanently, as it only needs CDM resources to check if server certificate is supported so CDM resources can be acquired before check and released afterwards

  2. CDMInstanceThunder object's CDM resources are released on HTMLMediaElement::stop() to not wait for Garbage Collector
    2c36c43

Build-Tests Layout-Tests
✅ 🛠 wpe-238-amd64-build ✅ 🧪 wpe-238-amd64-layout
✅ 🛠 wpe-238-arm32-build ✅ 🧪 wpe-238-arm32-layout

When HTMLMediaElement has been created in WPE and HTMLMediaElement::setMediaKeys()
method was called to set DRM keys, CDMThunder implementation already allocates CDM
resources and they're not released until HTMLMediaElement object is destructed.
HTMLMediaElement destruction is non-deterministic and it's relying on Garbage Collector.
In this case very often we observe that after WPE exit (WPE process is not closed,
but some #boot address is being loaded), CDM resources are not released immediately
and CDM can't be used by other applications like IP Player or Netflix.

Proposed solution introduces following changes:

1) CDMPrivateThunder implementation doesn't occupy CDM resources permanently,
as it only needs CDM resources to check if server certificate is supported
so CDM resources can be acquired before check and released afterwards

2) CDMInstanceThunder object's CDM resources are released on HTMLMediaElement::stop()
to not wait for Garbage Collector
@calvaris
Copy link
Member

I would need a test case, please.

@marcin-mielczarczyk-red
Copy link
Author

@calvaris is manual test case enough (description how to reproduce the problem)?

@calvaris
Copy link
Member

@calvaris is manual test case enough (description how to reproduce the problem)?

yes.

@calvaris
Copy link
Member

but it has to show that the resources are not released before the patch and are released after building with the patch.

@marcin-mielczarczyk-red
Copy link
Author

To reproduce the problem below steps should be performed:

  1. start application which uses DRM (most often it reproduces in Apple or Film1)
  2. start video playback and keep playing for 2-3 minutes
  3. exit application (or load URL from a different domain, for example "google.com")
  4. repeat above steps multiple times
    Sometimes (once per 20 times or even more seldom) DRM session is not released because HTMLMediaElement is not freed (seems that reference is kept by some object). Triggering garbage collector manually doesn't help (I tried multiple times).
    Without proposed patch the only way to release DRM session is to load "about:blank", which causes freeing of HTMLMediaElement and frees DRM session in result.

@eocanha
Copy link
Member

eocanha commented Jan 16, 2026

Might the retained HTMLMediaElement issue have been solved by this recent commit (in wpe-2.46, might be applicable to wpe-2.38 too)?
4c72cef

@marcin-mielczarczyk-red
Copy link
Author

Might the retained HTMLMediaElement issue have been solved by this recent commit (in wpe-2.46, might be applicable to wpe-2.38 too)? 4c72cef

This patch is applicable to 2.38 and looks related to issue we're observing.
Original root cause of DRM not being released is a leaked HTMLMediaElement so that would be a better solution.
Thank you for pointing it out. Will perform tests and update this ticket.

@eocanha
Copy link
Member

eocanha commented Jan 16, 2026

Patch proactively backported it to wpe-2.38 as a087bcd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

4 participants