Bug 173051 - Poor performance with asm.js
Summary: Poor performance with asm.js
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-07 03:40 PDT by Ashley Gullen
Modified: 2017-06-13 09:46 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ashley Gullen 2017-06-07 03:40:26 PDT
Safari doesn't support any open codecs so we're using an asm.js compile of ffmpeg to decode Opus audio here: https://www.scirra.com/labs/audiotest/

The page is very slow to load on an iPad Air 2, despite not processing much data. It only decodes 23 files totalling ~750kb of compressed data. However this considerably slows down loading times for web content that uses this approach.
Comment 1 Alexey Proskuryakov 2017-06-07 10:10:36 PDT
Could you please clarify how to reproduce the issue?

When I load this page on an iPhone 7, WebContent process unexpectedly terminates. On a Mac, I see an "audio test" image after a progress indicator.

How can I measure performance, and how can I confirm that this is a WebKit deficiency? Are other browser engined doing better in some way?
Comment 2 Ashley Gullen 2017-06-07 10:21:44 PDT
Ah, we've actually seen the page terminating as another case, but I couldn't immediately reproduce that. Could that be investigated as the issue instead? I'm sure asm.js is causing some kind of memory leak/crash, and that may be related to the poor performance.
Comment 3 Alexey Proskuryakov 2017-06-07 12:31:24 PDT
JavaScriptCore doesn't have custom code for asm.js, it's just normal JavaScript for us. So this could be a general JavaScriptCore issue, or a bug in your code.

Could you please answer the questions that I asked in the previous comment?
Comment 4 Ashley Gullen 2017-06-08 03:39:53 PDT
Surely a bug in JavaScript code should not be able to terminate the process? That is definitely a Safari bug if that happens right?

We desperately need a way to play a single set of audio files across browsers, so our goal is simply to have a feasible way to decode Opus files in Safari. I made a tweaked version of the test that always uses the asm.js decoder in other browsers even if they natively support Opus: https://www.scirra.com/labs/audiotest/

Safari on a Macbook performed reasonably compared to Chrome on the same test, so actually I am not really concerned about macOS. I am most concerned about iOS. On the iPad Air 2 I timed its loading performance with a stopwatch and it took around 30 seconds to load the page. I hope you would agree this is an exceptional amount of time for decoding ~750kb of audio data. Since Apple bans other browser engines on iOS I don't know how to make a fair comparison; is there anything you would recommend? All I have to go with is the absolute time, which does seem high. Crashing the browser process is also a major problem, since it means we don't have a way to decode the audio at all, even slowly.

Apologies for taking a few comments to clarify the issue: never mind about macOS, I am only concerned with iOS here.
Comment 5 Ashley Gullen 2017-06-08 03:40:35 PDT
Sorry, the link for the test that always uses the asm.js decoder is actually https://www.scirra.com/labs/audiotest2
Comment 6 Alexey Proskuryakov 2017-06-08 21:07:47 PDT
> Surely a bug in JavaScript code should not be able to terminate the process? That is definitely a Safari bug if that happens right?

This is not necessarily the case, a webpage that attempts to use too much RAM will be terminated before it makes the phone unusable.

> I hope you would agree this is an exceptional amount of time for decoding ~750kb of audio data.

There is no way for me to tell if it's a browser engine deficiency from this alone.

What is the best time you get from any mobile browser on any platform, using this same asm.js program? Any desktop browser? Please provide hardware characteristics for a fair comparison. An iPad Air 2 was released in 2014, so it's not the fastest hardware in existence any more.
Comment 7 Ashley Gullen 2017-06-13 08:13:13 PDT
Agh, turns out you're right - I tried with a Nexus 9 and it was still super slow. I guess it's my fault for just assuming asm.js would be fast! We must have done something wrong with the build for it. Sorry for the misleading report.
Comment 8 Alexey Proskuryakov 2017-06-13 09:46:31 PDT
Thank you for following up!