Skip to content

Commit

Permalink
Dispatch Flash events asynchronously (#3700)
Browse files Browse the repository at this point in the history
Flash blocks until the javascript side of ExternalInterface callbacks complete and swallows any exceptions generated during that process. To avoid performance issues and missed exceptions, trigger events from Flash asynchronously.
  • Loading branch information
dmlap committed Oct 26, 2016
1 parent 254683b commit f599ef4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/js/tech/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,16 @@ Flash.checkReady = function(tech) {
// Trigger events from the swf on the player
Flash.onEvent = function(swfID, eventName) {
const tech = Dom.getEl(swfID).tech;

tech.trigger(eventName, Array.prototype.slice.call(arguments, 2));
const args = Array.prototype.slice.call(arguments, 2);

// dispatch Flash events asynchronously for two reasons:
// - Flash swallows any exceptions generated by javascript it
// invokes
// - Flash is suspended until the javascript returns which may cause
// playback performance issues
tech.setTimeout(function() {
tech.trigger(eventName, args);
}, 1);
};

// Log errors from the swf
Expand Down

0 comments on commit f599ef4

Please sign in to comment.