Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User reported issue: Encoding Error: Decoding Failed #151

Closed
oliver-phet opened this issue Sep 23, 2021 · 39 comments
Closed

User reported issue: Encoding Error: Decoding Failed #151

oliver-phet opened this issue Sep 23, 2021 · 39 comments
Assignees

Comments

@oliver-phet
Copy link

image

Been using your excellent science sims for some time now, both on iPad & my MacBook air but today when i logged in on the MacBook during an online lesson to use the physics circuit construction kit apps neither would work. They’ve always worked while doing a zoom lesson before. After the session i retried but again these two apps just hung up with the loading bar flashing. I tried several other apps and they all seem to be working fine. (my student did get the sim working on her PC during the session but i couldn’t interact with it)

I’ve got Mac OS Catalina 10.15.7 & Safari version 15.0

I'm still awaiting a detailed system report from the user.

@oliver-phet
Copy link
Author

System report (from a working sim, Capacitor Lab):

Troubleshooting information:
!!!!! DO NOT EDIT !!!!!
Name: ‪Capacitor Lab: Basics‬
URL: https://phet.colorado.edu/sims/html/capacitor-lab-basics/latest/capacitor-lab-basics_en.html
Version: 1.6.21 2021-09-23 04:32:40 UTC
Features missing: touch
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 Safari/605.1.15
Language: en-GB
Window: 1440x738
Pixel Ratio: 1/1
WebGL: WebGL 1.0
GLSL: WebGL GLSL ES 1.0 (1.0)
Vendor: WebKit (WebKit WebGL)
Vertex: attribs: 16 varying: 15 uniform: 1024
Texture: size: 16384 imageUnits: 16 (vertex: 16, combined: 32)
Max viewport: 16384x16384
OES_texture_float: true

@samreid
Copy link
Member

samreid commented Sep 28, 2021

@arouinfar and I noticed that the error trace looks related to audio. @jbphet can you take a look? Should we request the client try other sims with sound? We aren't sure if some sims have synthesized sound vs sound clips, so we aren't sure where to go.

@samreid samreid assigned jbphet and unassigned samreid Sep 28, 2021
@jbphet
Copy link
Contributor

jbphet commented Sep 30, 2021

@samreid said:

@arouinfar and I noticed that the error trace looks related to audio.

This problem is definitely related to audio. The failure is occurring when the sim tries to decode the base64-encoded data that represents a pre-recorded sound clip, but unfortunately the information above gives us little insight into why this is happening. I dug into the first failure a bit based on the line number information in the screenshot above, and I'm reasonably confident that it's occurring during the loading of accordion_box_open_mp3.js. There isn't anything particularly significant about it being this file other than that it's a common-code sound.

By design, the sound files try to create a stubbed, blank audio buffer if the decode fails, but it appears that this error-handling path is not working, which is the source of the error message in the trace that says, NotSupportedError: Length must be at least 1. Web Audio is essentially saying that the audio buffer can't be of zero length. I replicated this error on Chrome on my Windows machine by removing the first character in the base64 encoding of the audio (i.e. the 's' after the first '//') in accordion_box_open_mp3.js and trying to run CCK DC virtual lab. In this situation, I got the following DOM exception:

DOMException: Failed to execute 'createBuffer' on 'BaseAudioContext': The number of frames provided (0) is less than or equal to the minimum bound (0).

So, we basically have a double failure on our hands: The audio fails to decode on the user's system, and the error recovery path causes an exception. I'm not sure whether this error recovery path was always broken (which would be rather lame on my part) or if something has changed in the Web Audio spec. I tried changing the code in the error path to create a 1-frame sound instead of a 0-frame sound, and the DOM exception stopped happening, so this is a promising improvement.

Also, there is a message at the end of the user's trace that says Unhandled Promise Rejection: Decoding failed. I looked into this one too, and it looks like the call to auidoContext.decodeAudioData returns a Promise which can fail too. It strikes me as odd to support an error-handler callback and to also reject the promise and require that it be caught, but I guess that's just the way it is. I added a catch handler in the audio decode code, and it prevented this error message from happening.

We may be able to fix the problem and make sims run successfully when audio decoding fails by implementing one or both of the items described above, but it would help to have a bit more information before putting any more time into this. Here are some requests:

@oliver-phet - Can you please thank the user who reported this for doing so, let them know that it is a problem related to decoding sound files that are used in the sim, and ask them the following questions:

@KatieWoe - Do we have a Mac with the OS version that the user lists above?

Below is a patch of the changes that might resolve this issue. Note that if we do this, we'll have to maintenance release pretty much every sim released since we started doing sounds in these _mp3.js files.

Index: sounds/accordion-box-open_mp3.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/sounds/accordion-box-open_mp3.js b/sounds/accordion-box-open_mp3.js
--- a/sounds/accordion-box-open_mp3.js	(revision 176f9875414c29310834471086c753e08728a3b7)
+++ b/sounds/accordion-box-open_mp3.js	(date 1632959870328)
@@ -14,8 +14,10 @@
 };
 const onDecodeError = decodeError => {
   console.warn( 'decode of audio data failed, using stubbed sound, error: ' + decodeError );
-  wrappedAudioBuffer.audioBufferProperty.set( phetAudioContext.createBuffer( 1, 0, phetAudioContext.sampleRate ) );
+  wrappedAudioBuffer.audioBufferProperty.set( phetAudioContext.createBuffer( 1, 1, phetAudioContext.sampleRate ) );
   unlock();
 };
-phetAudioContext.decodeAudioData( soundByteArray.buffer, onDecodeSuccess, onDecodeError );
+phetAudioContext.decodeAudioData( soundByteArray.buffer, onDecodeSuccess, onDecodeError ).catch( error => {
+  console.warn( `promise rejection caught for audio decode, error = ${error}` );
+} );
 export default wrappedAudioBuffer;
\ No newline at end of file

@KatieWoe
Copy link

We do have MacOS 10.15.7.

@samreid
Copy link
Member

samreid commented Sep 30, 2021

@jbphet should this be moved to another repo?

@oliver-phet
Copy link
Author

@jbphet reply from user:

Is there is anything unusual about the audio setup for the computer where this problem occurs?

Have checked my Macbook air sound settings and all seems normal. using internal mc & speakers & they’re working during Zoom sessions and for youtube, music & sound clip playback

Do they have a similar problem if they load https://phet.colorado.edu/sims/html/resistance-in-a-wire/latest/resistance-in-a-wire_en.html on the same machine? If it loads, does sound work?

resistance sim visuals & sliders work fine there is no sound (even with the sound speaker unchecked)

Would they be willing to try a modified version of the sim if we sent them a link so that we can test out a potential fix?

Yup.. i’d defo be up for trying a modified version of the sim on my machine…

ON: The user also found an older version (1.1.5) that doesn't exhibit the issue. Would it be helpful for you to have the user identify the exact version this problem was introduced?

@oliver-phet oliver-phet removed their assignment Sep 30, 2021
@samreid
Copy link
Member

samreid commented Sep 30, 2021

@jbphet reviewed this problem today:

CM: Will this affect RC's from, say, yesterday?
JB: Yes, but we would catch that in the maintenance release? It seems a rare problem, but I can hack it to make the problem occur. But I don't know exactly what it is on the client's machine that may be triggering it. One proposed fix would allow the sim to run, but without sound.

@samreid samreid transferred this issue from phetsims/circuit-construction-kit-common Sep 30, 2021
@KatieWoe
Copy link

I reproduced this on our test device in Safari, but not in Chrome. I tested it on MacOS 11 running Safari 14 and didn't see it. I'm updating it now to Safari 15 (the 10.15 device was already on Safari 15). If it is introduced then, that may help us further.

@KatieWoe
Copy link

It did not happen on MacOS 11 Safari 15

@jbphet
Copy link
Contributor

jbphet commented Sep 30, 2021

@oliver-phet said:

The user also found an older version (1.1.5) that doesn't exhibit the issue. Would it be helpful for you to have the user identify the exact version this problem was introduced?

Sure, if they are willing to do that, it would be very helpful.

@oliver-phet
Copy link
Author

@jbphet:

all of the versions 1.2.0 up to 1.2.4 i tried the _all.html & _en.html files and they all hang up

Sounds like this issue was introduced in 1.2.0.

@oliver-phet oliver-phet removed their assignment Oct 1, 2021
@arouinfar
Copy link

Sound was introduced in the 1.2 version, as were several other features and model improvements. Settling for the 1.1 version is a step down in functionality, but certainly better than nothing at all.

@pixelzoom
Copy link
Contributor

pixelzoom commented Oct 1, 2021

This problem has now appeared in RC testing for Fourier, see phetsims/fourier-making-waves#202. Raising priority to high.

Note that the report in Fourier is also on macOS Catalina 10.15.7 + Safari 15.0, the same platform originally reported here. Safari 15.0 is the latest version of Safari, which as been back-ported to (some) older versions of macOS.

This problem does not appear on my wife's MacBookPro11,1 (Mid 2014) with macOS 10.15.6 + Safari 13.1.2.

@jbphet
Copy link
Contributor

jbphet commented Oct 4, 2021

I added better error handling and re-modulified the sounds in tambo, joist, vegas, and scenery-phet because those were the repos with sounds being used by the fourier-making-waves sim. I then worked with @Nancy-Salpepi to test out fourier on the machine where the problem can be duplicated. The sim loaded successfully, and printed out the expected console warnings. For reference, I've included the output below. There are essentially two error messages produced per decoding failure.

[Warning] decode of audio data failed, using stubbed sound, error: null (empty_apartment_bedroom_06_resampled_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (empty_apartment_bedroom_06_resampled_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (screen-selection-home-v3_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (screen-selection-home-v3_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (switching-screen-selector-icons-003_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (switching-screen-selector-icons-003_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (general-button-v4_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (general-button-v4_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (general-close_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (general-close_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (general-open_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (general-open_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (checkbox-checked_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (checkbox-checked_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (checkbox-unchecked_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (checkbox-unchecked_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (radio-button-v2_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (radio-button-v2_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (step-back-v2_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (step-back-v2_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (step-forward-v2_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (step-forward-v2_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (screen-selection_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (screen-selection_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (pause_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (pause_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (play-pause-003_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (play-pause-003_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (general-boundary-boop_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (general-boundary-boop_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (general-soft-click_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (general-soft-click_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (reset-all_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (reset-all_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (boing_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (boing_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (cheer_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (cheer_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (ding_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (ding_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (organ_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (organ_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (trumpet_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (trumpet_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (go-back_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (go-back_mp3.js, line 21) [Warning] decode of audio data failed, using stubbed sound, error: null (level-selection-button_mp3.js, line 16) [Warning] promise rejection caught for audio decode, error = EncodingError: Decoding failed (level-selection-button_mp3.js, line 21)

It should be noted that this is a partial solution to the problem. The better error handling will allow sims to load when audio decoding fails, but we still don't know why we are running into audio decode errors on this particular configuration of MacOS and Safari version, nor what, if anything, we can do about it.

jbphet added a commit to phetsims/faradays-law that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/graphing-quadratics that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/gravity-and-orbits that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/gravity-and-orbits that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/greenhouse-effect that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/john-travoltage that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/molecule-polarity that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/molecules-and-light that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/natural-selection that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/natural-selection that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/natural-selection that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/number-line-distance that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/number-line-integers that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/number-line-operations that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/ph-scale that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/ph-scale-basics that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/ratio-and-proportion that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/states-of-matter that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/states-of-matter-basics that referenced this issue Oct 13, 2021
jbphet added a commit to phetsims/waves-intro that referenced this issue Oct 13, 2021
@jbphet
Copy link
Contributor

jbphet commented Oct 14, 2021

@oliver-phet - Can you ask the original reporter of this issue to try the sim again? You can let them know that we've fixed an issue that was specific to that OS and browser configuration.

@jbphet jbphet assigned oliver-phet and unassigned KatieWoe Oct 14, 2021
@mattpen
Copy link

mattpen commented Oct 14, 2021

@jbphet - @zepumph and I checked the database and filesystem entries (including .htaccess files) for the failed phet-io deployments, and everything seems to have worked correctly.

Here are the sims we checked:
Sim = molecule-polarity Version = 1.2.2
Sim = greenhouse-effect Version = 1.0.1
Sim = gravity-and-orbits Version = 1.5.2
Sim = gravity-and-orbits Version = 1.4.3
Sim = graphing-quadratics Version = 1.2.2
Sim = energy-forms-and-changes Version = 1.4.3

@jbphet
Copy link
Contributor

jbphet commented Oct 14, 2021

That's good news @mattpen! Based on this, I think our work here is done.

I'll leave this open to record what we hear from the user who originally reported the issue (@oliver-phet is going to contact them) so that we can fully close the loop on this issue. @oliver-phet - If the user reports that the sim now loads for them, you can go ahead and close.

@jbphet jbphet removed their assignment Oct 14, 2021
@oliver-phet
Copy link
Author

@jbphet:

You stars!!!
just tried it out and all working perfectly on my macbook air now

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

No branches or pull requests

10 participants