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

Low runner "createBuffer" error on iOS #654

Open
bflora2 opened this issue Nov 23, 2016 · 14 comments · May be fixed by #1363
Open

Low runner "createBuffer" error on iOS #654

bflora2 opened this issue Nov 23, 2016 · 14 comments · May be fixed by #1363

Comments

@bflora2
Copy link

bflora2 commented Nov 23, 2016

I am receiving reports of the following error from the field: null is not an object (evaluating 'e.ctx.createBuffer'). The error occurs in Howler 2.0.1 (minified) when running the following code:

new Howl({
   src: [ 'https://cdn.jigsawexplorer.com/puzzles/resources/audio/applause.webm',
          'https://cdn.jigsawexplorer.com/puzzles/resources/audio/applause.mp3' ],
   volume: 0.3,
   onload: callback,
   onloaderror: errCallback
});

The error appears to be coming from line 263 in howler.js (unminified).

The error only occurs on iOS devices, and it occurs for much less than 1% of iOS devices. However, devices that generate the error tend to generate it again in future sessions. I have been seeing the error for a number of months (it is not new to v2.0.1). I cannot recreate the error on my iPad.

If you need more information then I can add code to gather additional data when the error occurs. Just let me know what you would need.

@bflora2
Copy link
Author

bflora2 commented Nov 24, 2016

Correction: I've just received the same error for an Android device. After checking again I found two other earlier reports of this error from Android devices. So, it is not just iOS as I had incorrectly stated earlier, but no PCs or Macs have reported this error.

@goldfire
Copy link
Owner

goldfire commented Dec 4, 2016

Is this the line you are saying the error is firing on?

self._scratchBuffer = self.ctx.createBuffer(1, 1, 22050);

@bflora2
Copy link
Author

bflora2 commented Dec 4, 2016

Yes. Apparently, in rare situations on iOS and (even rarer) on Android, the value of ctx is null on that line.

@goldfire
Copy link
Owner

goldfire commented Dec 4, 2016

Are you 100% it is referencing that line? A few lines above it already checks if self.ctx is set, so I'm not sure how it could possibly be null at that line.

@bflora2
Copy link
Author

bflora2 commented Dec 5, 2016

Yes, I'm sure. That is the only line in the source that calls ctx.createBuffer.

Yes, there is a null check performed on ctx a half dozen lines before the error is thrown. But, below that, immediately before the error is thrown, there appears to be an opportunity to call self.unload which can set ctx to null.

@bflora2
Copy link
Author

bflora2 commented Dec 13, 2016

After placing some log traces in the Howler code I now see the cause of the problem: The call to self.unload (line 292, v2.0.2) sets self.ctx to null. unload then calls setupAudioContext which normally assigns a new audio context to self.ctx, but in rare cases setupAudioContext will throw an error from native code due to a lack of audio resources. That means self.ctx is left set to null when unload returns, which in turn, causes self._scratchBuffer = self.ctx.createBuffer(1, 1, 22050) (line 297, v2.0.2) to throw an unhandled error.

It appears the problem can be fixed by adding a null check after the call to self.unload (line 292, v2.0.2):

if (!self._mobileUnloaded && self.ctx.sampleRate !== 44100) {
  self._mobileUnloaded = true;
  self.unload();

  if (!self.ctx) {
    return;
  }
}

@lbarthon lbarthon linked a pull request Jun 17, 2020 that will close this issue
@AmirL
Copy link

AmirL commented Jun 18, 2020

BTW, The bug is still there :(.

@lbarthon
Copy link

Yes, fixed with #1363, waiting for a merge

@Ch1pStar
Copy link

Ch1pStar commented Jul 21, 2020

Hello, we're currently experiencing this error in some very specific situations on iOS Safari. As a temp fix in addition to the MR above, I'm setting self.noAudio=true and returning, because otherwise Howler attempts to call ctx.createGain in Howler.load

@hmoffatt
Copy link

I am getting lots of null errors from inside the unlock function, different to the error above.
null is not an object (evaluating 'e.ctx.createBufferSource')

somehow ctx is valid when the touch handlers are added but not later when executed.

@lbarthon
Copy link

Maybe an up here? My pr has been opened for half a year now..

@0xdevalias
Copy link

0xdevalias commented Apr 5, 2021

We're also seeing this issue pop up sporadically, would be awesome #1363 could get merged or another similar fix.

@goldfire and/or any other contributors able to weigh in here?


image
image


While it might not be the same 'root cause', we are also seeing the following, which feels very similar to this issue:

TypeError null is not an object (evaluating 'e.ctx.suspend') 
    ../node_modules/howler/dist/howler.js:498:17 

image

image

I haven't done any deeper tracing to identify the specifics of it at this stage, as it's only affecting a small number of Safari users at this stage.


While it may not be related to this, when googling for the error I stumbled across the following, which sounds similar (though probably not as useful as the explicit tracing done in #654 (comment)):

@lbarthon
Copy link

lbarthon commented Apr 6, 2021

@hmoffatt
Copy link

@0xdevalias I also see the suspend issue. Always Safari.

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

Successfully merging a pull request may close this issue.

7 participants