# "Media resource could not be decoded" in extensions

**URL:** <https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111>\
**Category:** Development\
**Tags:** learning, issue\
**Created:** [May 10, 2025, 3:50am UTC](https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111 "2025-05-10T03:50:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![monyxie](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/monyxie/32/65361_2.png) [@monyxie](https://discourse.mozilla.org/u/monyxie)\
**Post date:** [May 10, 2025, 3:50am UTC](https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111/1 "2025-05-10T03:50:34Z")

</div>

Hello everyone.

One of my extension needs to play an audio file in response to some events but it sometimes fails to do so. When that happens, the following messages are logged in the console:

```auto
Media resource moz-extension://c2e41295-cd60-48cd-bee0-e62a562d3d43/audio/success.mp3 could not be decoded.Uncaught (in promise) DOMException: The media resource indicated by the src attribute or assigned media provider object was not suitable.
Media resource moz-extension://c2e41295-cd60-48cd-bee0-e62a562d3d43/audio/success.mp3 could not be decoded, error: Error Code: NS_ERROR_DOM_MEDIA_METADATA_ERR (0x806e0006)

```

The code I’m using to play the audio file looks something like:

```auto
const audio = new Audio('audio.mp3');
audio.play()

```

But the same thing also happens with an `<audio>` tag.

Please see this minimal extension I created to investigate the issue:  
[test-extension.zip](https://discourse.mozilla.org/uploads/short-url/lLtOVoMf6mSLDG35l9D5bKUzvJ1.zip) (9.0 KB)

Once you install the extension, click the action icon to open the test page. The test page simply renders 40 `<audio>` elements that load the same mp3 file. If you open the console and keep refreshing the page, you will eventually see the messages above.

Note that it happens no matter how many `<audio>` tags there is, I made it 40 just to increase the chance of hitting the issue.

The same page using the same code but loaded via HTTP doesn’t have this problem.

Does anyone have an idea about why this is happening? Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![irvinm](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/irvinm/32/22968_2.png) [@irvinm](https://discourse.mozilla.org/u/irvinm)\
**Post date:** [May 11, 2025, 3:27pm UTC](https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111/2 "2025-05-11T15:27:38Z")

</div>

I got it to work by updating manifest.json to specifically allow “web\_accessible\_resources”.

```auto
{
  "manifest_version": 3,
  "name": "Test Extension",
  "version": "0.1",
  "description": "For Testing Only",
  "icons": {
    "48": "icons/quicknote-48.png"
  },
  "permissions": [],
  "action": {
    "default_icon": {
      "32": "icons/quicknote-32.png"
    },
    "default_title": "Test Extension"
  },
  "background": {
    "scripts": ["background.js"],
    "service_worker": "background.js"
  },
  "web_accessible_resources": [
    {
      "resources": ["audio/success.mp3"],
      "matches": ["<all_urls>"]
    }
  ]
}

```

---

<div class="post-metadata">

**Author:** ![monyxie](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/monyxie/32/65361_2.png) [@monyxie](https://discourse.mozilla.org/u/monyxie)\
**Post date:** [May 11, 2025, 4:00pm UTC](https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111/3 "2025-05-11T16:00:19Z")

</div>

Thank you for your reply!

Unfortunately adding `web_accessible_resources` doesn’t seem to work on my end. I still see the same warning messages in the console once every few refreshes.

 ![image](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/b/8/b8094b3891fe7a3df994ad866999cf6107c71f1e.png)

The mp3 file is being accessed in an extension page. As far as I know, this isn’t classified as “web access”. So it doesn’t make much sense to add it to `web_accessible_resources`. It doesn’t explain why it only fails _sometimes_ either.

---

<div class="post-metadata">

**Author:** ![irvinm](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/irvinm/32/22968_2.png) [@irvinm](https://discourse.mozilla.org/u/irvinm)\
**Post date:** [May 11, 2025, 4:35pm UTC](https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111/4 "2025-05-11T16:35:13Z")

</div>

Agreed and honestly I don’t have enough experience to explain. There are several people here that will likely be able to fill in the gaps or provide better explanations or solutions.

With your default project I got the following and the same errors you saw:

 ![image](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/8/f/8feb8e81add3e0150c695aacf6e632c79dbbc08f.png)

After the manifest change and reloading the extension, I got the following without any errors:

 ![image](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/8/2/82e147e4905d439f245ee51a577927762ad20bc7.png)

---

<div class="post-metadata">

**Author:** ![monyxie](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/monyxie/32/65361_2.png) [@monyxie](https://discourse.mozilla.org/u/monyxie)\
**Post date:** [May 11, 2025, 4:41pm UTC](https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111/5 "2025-05-11T16:41:55Z")

</div>

Did you refresh the page? Sometimes it takes tens of refreshes to hit the issue.

---

<div class="post-metadata">

**Author:** ![irvinm](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/irvinm/32/22968_2.png) [@irvinm](https://discourse.mozilla.org/u/irvinm)\
**Post date:** [May 11, 2025, 5:46pm UTC](https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111/6 "2025-05-11T17:46:25Z")

</div>

I just tried this and it did take several/many times, but I was able to reproduce it. ☹

Given the behavior that it works most of the time, but fails infrequently tells me it is likely a Firefox issue. Let’s see what others have as suggestions on this topic.

 ![image](https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/6/e/6ea7cdb10fc0735ea19d59d46c2f096ae14a2f48.png)

---

<div class="post-metadata">

**Author:** ![irvinm](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/irvinm/32/22968_2.png) [@irvinm](https://discourse.mozilla.org/u/irvinm)\
**Post date:** [May 11, 2025, 5:48pm UTC](https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111/7 "2025-05-11T17:48:57Z")

</div>

Oh … and did want to say that I think you are right about the manifest.json change. It isn’t needed. I just tried with the original version and see the same behavior. Sorry about that.

---

<div class="post-metadata">

**Author:** ![monyxie](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/monyxie/32/65361_2.png) [@monyxie](https://discourse.mozilla.org/u/monyxie)\
**Post date:** [May 11, 2025, 5:54pm UTC](https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111/8 "2025-05-11T17:54:11Z")

</div>

No problem. I appreciate your replies.

---

<div class="post-metadata">

**Author:** ![dotproto](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/dotproto/32/62957_2.png) [@dotproto](https://discourse.mozilla.org/u/dotproto)\
**Post date:** [May 12, 2025, 7:42pm UTC](https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111/9 "2025-05-12T19:42:51Z")

</div>

This is quite curious. Thanks for putting together a minimal reproduction case, @monyxie. I was also able to reproduce the bug locally on macOS 15.4.1 using Firefox Nightly 140.0a1 (2025-05-11).

If you haven’t already, please file a new [WebExtensions bug](https://bugzilla.mozilla.org/enter_bug.cgi?product=WebExtensions) for this issue.

---

<div class="post-metadata">

**Author:** ![monyxie](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/monyxie/32/65361_2.png) [@monyxie](https://discourse.mozilla.org/u/monyxie)\
**Post date:** [May 13, 2025, 12:25am UTC](https://discourse.mozilla.org/t/media-resource-could-not-be-decoded-in-extensions/143111/10 "2025-05-13T00:25:37Z")

</div>

Thank you for your help. I have filed [#1965971](https://bugzilla.mozilla.org/show_bug.cgi?id=1965971) just now.
