Reloading after creating AudioContext causes InvalidStateError

VERIFIED FIXED in Firefox 67

Status

()

defect
P2
normal
VERIFIED FIXED
4 months ago
Last month

People

(Reporter: omgitsraven, Assigned: padenot)

Tracking

({regression})

63 Branch
mozilla68
Points:
---

Firefox Tracking Flags

(firefox-esr60 unaffected, firefox65 wontfix, firefox66 wontfix, firefox67+ verified, firefox68 verified)

Details

Attachments

(1 attachment)

Reporter

Description

4 months ago

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0

Steps to reproduce:

  1. Visit a page containing a script tag that contains "new AudioContext()", i.e.: http://ravenworks.ca/temp/audioctx.html
  2. Open the console
  3. Reload the page

Actual results:

A red error appears, saying " InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable"

Expected results:

Nothing.

For a slightly more complex example: http://ravenworks.ca/temp/audioctx_click.html Here the AudioContext is only created if the text is clicked, and in that case, the error only appears when reloading after having clicked the text, not when reloading after having done nothing.

Updated

4 months ago
Component: Untriaged → Web Audio
Product: Firefox → Core

Updated

4 months ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: regression
Version: 65 Branch → 63 Branch

Comment 1

4 months ago

Regression window:
https://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=7eb7606a2b12990e8ef5e470db27838d5f5af612&tochange=7ccc1c8a7abeefd54bc4cf9a5d0eef23681c924a

Suspect: Bug 1486130

:kmag,
Your bunch of patch seems to cause the error message.
Can you please look into this?

Blocks: 1486130
Flags: needinfo?(kmaglione+bmo)

My patch does not cause the error. It just stops it from being hidden.

Flags: needinfo?(kmaglione+bmo)
No longer blocks: 1486130
Priority: -- → P2

Karl, who is the best assignee for this bug?

Flags: needinfo?(karlt)

This is the stack generating the unhandled rejected promise.

#8 0x00007fd8ce466c35 in mozilla::dom::Promise::MaybeReject(nsresult)
(this=0x7fd8c94a5460, aArg=-2142044149)
at /var/karl/moz/obj/dist/include/mozilla/dom/Promise.h:94
#9 0x00007fd8d2b07a60 in mozilla::dom::AudioContext::Shutdown()
(this=0x7fd8e62b4f80)
at /home/karl/moz/dev/dom/media/webaudio/AudioContext.cpp:716
#10 0x00007fd8d05bd3e1 in nsGlobalWindowInner::FreeInnerObjects()
(this=0x7fd8c9209c00)
at /home/karl/moz/dev/dom/base/nsGlobalWindowInner.cpp:1162
#11 0x00007fd8d0601193 in nsGlobalWindowOuter::SetNewDocument(mozilla::dom::Document*, nsISupports*, bool)
(this=0x7fd8c96bf4c0, aDocument=0x7fd8c78f1000, aState=0x0, aForceReuseInnerWindow=false) at /home/karl/moz/dev/dom/base/nsGlobalWindowOuter.cpp:2242

https://searchfox.org/mozilla-central/rev/7c20ad925005fbad7b8e08813115f1ec7fa1c248/dom/media/webaudio/AudioContext.cpp#707

I assume this is the ignored promise from the Close() above.

If the promise is ignored, then perhaps the MaybeReject() loop can be moved to before the Close() call.
https://hg.mozilla.org/mozilla-central/rev/353266dd63ede28fd3f8f5ddd8d855f5beb7395d#l1.12

"global is going away soon" sounds similar to this situation, but I don't know much about that:
https://hg.mozilla.org/mozilla-central/rev/8e22b608af25e273d0cc5d6347bd1112f9de1be1#l1.67

Paul, do you know whether this situation is related to bug 1325215?

Flags: needinfo?(karlt) → needinfo?(padenot)

(In reply to Karl Tomlinson (:karlt) from comment #4)

Paul, do you know whether this situation is related to

bug 1343550, I meant.

Assignee

Comment 6

3 months ago

This is done in the same style as ::Suspend and ::Resume.

Assignee

Comment 7

3 months ago

Thanks for the analysis, Karl.

Flags: needinfo?(padenot)
Assignee

Updated

3 months ago
Assignee: nobody → padenot

Comment 8

3 months ago
Pushed by padenot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3a9d2f91b022
Don't create a Promise when shutting down an AudioContext. r=karlt

Comment 9

3 months ago
bugherder
Status: NEW → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68

Hi Paul, since 67 is marked as affected, should we consider uplifting this to Beta67?

Flags: needinfo?(padenot)
Assignee

Comment 11

3 months ago

Comment on attachment 9052872 [details]
Bug 1528319 - Don't create a Promise when shutting down an AudioContext. r=karlt

Beta/Release Uplift Approval Request

  • Feature/Bug causing the regression: Bug 1486130
  • User impact if declined: Bug 1486130 made it so that the error stopped being hidden. It's quite benign, but can also be puzzling for developers: it's seemingly an error that only happens during the onloading of a document, but the console persists between reload, so it looks like an error at loading a bit.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): This is doing the same thing we've been doing for quite some time on the two other methods for the same feature (suspend/resume/close, this is handling the close bit), and we never had any issues with the other ones.
  • String changes made/needed:
Flags: needinfo?(padenot)
Attachment #9052872 - Flags: approval-mozilla-beta?
https://hg.mozilla.org/projects/ash/rev/3a9d2f91b02203fc9e538fcfe51e2cb5cf620b29
Bug 1528319 - Don't create a Promise when shutting down an AudioContext. r=karlt

[Tracking Requested - why for this release]:
Paul has posted a patch for beta uplift in comment 11.

Flags: needinfo?(pascalc)
Flags: needinfo?(pascalc)

Comment on attachment 9052872 [details]
Bug 1528319 - Don't create a Promise when shutting down an AudioContext. r=karlt

Well understood fix affecting web developers working with audio only, verified on Nightly, uplift approved for 67 beta 7 thanks.

Attachment #9052872 - Flags: approval-mozilla-beta? → approval-mozilla-beta+

Comment 16

3 months ago

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0
Build ID: 20190331141835

Verified as fixed using the latest DevEdition Build and the latest Nightly Build (20190402083512). The Error is no longer displayed in the Console.

Status: RESOLVED → VERIFIED
Flags: qe-verify+

Updated

Last month
Regressions: 1549041
You need to log in before you can comment on or make changes to this bug.