aboutsummaryrefslogtreecommitdiff
path: root/src/library.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-07-18 18:14:21 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-07-18 18:14:21 -0700
commit076a9d247bde6cdba54065b8aaa9ba0400c9da71 (patch)
tree88e94d4fc107f23f88d7010626d00aea99360a00 /src/library.js
parent23f7aed49d983f693c26ed3dc980e4efbd7d40eb (diff)
add runDependency tracking and fix detected bugs
Diffstat (limited to 'src/library.js')
-rw-r--r--src/library.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/library.js b/src/library.js
index 8bee4521..a3628179 100644
--- a/src/library.js
+++ b/src/library.js
@@ -313,8 +313,8 @@ LibraryManager.library = {
ctx.drawImage(img, 0, 0);
Module["preloadedImages"][fullname] = canvas;
Browser.URLObject.revokeObjectURL(url);
- removeRunDependency();
if (onload) onload();
+ removeRunDependency('cp ' + fullname);
};
img.onerror = function(event) {
console.log('Image ' + url + ' could not be decoded');
@@ -331,14 +331,16 @@ LibraryManager.library = {
audio['oncanplaythrough'] = null;
Module["preloadedAudios"][fullname] = audio;
if (!audio.removedDependency) {
- removeRunDependency();
+ if (onload) onload();
+ removeRunDependency('cp ' + fullname);
audio.removedDependency = true;
}
};
audio.onerror = function(event) {
if (!audio.removedDependency) {
console.log('Audio ' + url + ' could not be decoded or timed out trying to decode');
- removeRunDependency(); // keep calm and carry on
+ if (onerror) onerror();
+ removeRunDependency('cp ' + fullname); // keep calm and carry on
audio.removedDependency = true;
}
};
@@ -346,14 +348,15 @@ LibraryManager.library = {
audio.src = url;
} else {
Module["preloadedAudios"][fullname] = new Audio(); // empty shim
- removeRunDependency();
+ if (onerror) onerror();
+ removeRunDependency('cp ' + fullname);
}
} else {
if (onload) onload();
- removeRunDependency();
+ removeRunDependency('cp ' + fullname);
}
}
- addRunDependency();
+ addRunDependency('cp ' + fullname);
if (typeof url == 'string') {
Browser.asyncLoad(url, function(byteArray) {
finish(byteArray);