Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weird behavior of CrossWalk-based hybrid app when playing m4a web audio

We have problems with an audio reader hybrid application, using fairly large audio m4a files. In short, it takes far too long to start the playback (when using online audio resources).

To illustrate the issue, we've created a smaller prototype with the following structure:

Body:

<audio src="..." controls="controls" preload="none"></audio>
<button class="change-current-time">Play and change currentTime</button>

Script:

var audioTags = document.querySelectorAll('audio');
[].forEach.call(audioTags, function (item) {
    item.addEventListener('play',       onPlayStateChange);
    item.addEventListener('timeupdate', onPlayStateChange);
    item.addEventListener('error',      onPlayStateChange);
    item.addEventListener('pause',      onPauseReset);
});

function onPlayStateChange(e) {
    var id = e.target.parentNode.id;
    if (count[id]) {
        return;
    }
    if (e.type === 'play') {
        count[id + 'start'] = +new Date();
    } else if (e.target.parentNode.querySelector('audio').currentTime > currentTimeOffset) {
    var span = e.target.parentNode.querySelector('span');
    count[id] = 1;
    if (span) {
       span.innerText = e.type === 'error' ? 'Audio type or codec does not supported' : new Date() - count[id + 'start'];
    }
  }
}

There is the full example.

When we build the app with Cordova 6.4.0 using WebView, it starts playback in ~3.5s. The network activity looks like this:

GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=webview HTTP/1.1   206 29522945
GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=webview HTTP/1.1   206 326657
GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=webview HTTP/1.1   206 29163520

When we build the app with Cordova 6.4.0 with Crosswalk-webview plugin 2.2.0, it starts playback in 18s at best, but sometimes the delay is even more substantial - up to 45s. It seems the main reason is the difference in the network activity:

GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=crosswalk HTTP/1.1 206 2
GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=crosswalk HTTP/1.1 200 29522945
GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=crosswalk HTTP/1.1 206 577690
GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=crosswalk HTTP/1.1 200 29522945
GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=crosswalk HTTP/1.1 206 577690
GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=crosswalk HTTP/1.1 200 29522945
GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=crosswalk HTTP/1.1 206 577690
GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=crosswalk HTTP/1.1 200 29522945
GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=crosswalk HTTP/1.1 206 577690
GET /tmp/1916firstchapterscollection_09_various_64kb.m4a?app=crosswalk HTTP/1.1 206 7384995

... when only the first request is served with the 'normal' user-agent, all the subsequent ones are served with stagefright/1.2 (Linux;Android 5.0.1).

Why's the difference, and how can we avoid this?

P.S. Here's the folder with all the apks and related data.

like image 755
Alex Avatar asked Jan 13 '17 17:01

Alex


1 Answers

If found any bug related to crosswalk plugin you can submit it on if not submitted yet https://crosswalk-project.org/jira/plugins/servlet/mobile#login/ Crosswalk project site, usualy they take imidiate action and resolve it. If you got it resolved please update answer here.

UPDATE

I found your(maybe yours) issue: https://crosswalk-project.org/jira/plugins/servlet/mobile#issue/XWALK-7484

Developers having same question track the issue on this link .. ATB

like image 64
Rohit Dhiman Avatar answered Oct 26 '22 00:10

Rohit Dhiman