Shaka-player: core-js Promise polyfill not working with Shaka Player on IE11

Created on 11 Oct 2017  路  9Comments  路  Source: google/shaka-player

Have you read the FAQ and checked for duplicate issues: Yes

What version of Shaka Player are you using: 2.2.2

Can you reproduce the issue with our latest release version: Yes 2.2.2

Can you reproduce the issue with the latest code from master: Not tried.

Are you using the demo app or your own custom app: Own app

If custom app, can you reproduce the issue using our demo app: No, not sure how I could.

What browser and OS are you using: IE11 (works in Edge, Chrome), Windows 10

What are the manifest and license server URIs:
(you can send the URIs to shaka-player-issues@google.com instead, but please use GitHub and the template for the rest)

What did you do?
Added promise polyfil ([email protected]) and use Shaka. eg:

import { shaka } from 'shaka-player/dist/shaka-player.compiled.debug';
import 'core-js/modules/es6.promise';

What did you expect to happen?
Playback to work.

What actually happened?
Get errors and no playback is possible.

IndexedDB.install
InputEvent.install
Patching input event support on IE.
mathRound.install
polyfill Math.round
MediaKeys.install
Using ms-prefixed EME v20140218
PatchedMediaKeysMs.install
MediaSource.install
Using native MSE as-is.
Using native Promises.
VideoPlayPromise.install
Using VTTCue polyfill from 3 argument TextTrackCue.
Unload latency: 0.041
Wrong error type!
load() failed: TypeError: [object Promise] is not iterable!
   "load() failed:"
   {
      [functions]: ,
      __proto__: { },
      message: "[object Promise] is not iterable!",
      name: "TypeError",
      stack: "TypeError: [object Promise] is not iterable!
   at module.exports (eval code:14:34)
   at Anonymous function (eval code:271:7)
   at perform (eval code:61:5)
   at all (eval code:267:5)
   at shaka.dash.MpdUtils.processXlinks (eval code:288:62)
   at shaka.dash.DashParser.prototype.parseManifest_ (eval code:389:214)
   at Anonymous function (eval code:388:374)
   at run (eval code:89:13)
   at Anonymous function (eval code:102:28)
   at flush (eval code:18:9)",
      Symbol()_h.u53ox2ia3cc: undefined,
      Symbol(observable)_k.u53ox2ia3cc: undefined,
      Symbol(react.element)_g.u53ox2ia3cc: undefined,
      Symbol(Symbol.asyncIterator)_i.u53ox2ia3cc: undefined,
      Symbol(Symbol.observable)_j.u53ox2ia3cc: undefined
   }

Followed by 10 - 15 repeats of

Unhandled promise rejection TypeError:  is not iterable!
   "Unhandled promise rejection"
   {
      [functions]: ,
      __proto__: { },
      message: " is not iterable!",
      name: "TypeError",
      stack: "TypeError:  is not iterable!
   at module.exports (eval code:14:34)
   at Anonymous function (eval code:271:7)
   at perform (eval code:61:5)
   at all (eval code:267:5)
   at shaka.dash.MpdUtils.processXlinks (eval code:288:62)
   at shaka.dash.MpdUtils.processXlinks (eval code:288:2)
   at shaka.dash.MpdUtils.processXlinks (eval code:288:2)
   at shaka.dash.MpdUtils.processXlinks (eval code:288:2)
   at shaka.dash.DashParser.prototype.parseManifest_ (eval code:389:214)
   at Anonymous function (eval code:388:374)",
      Symbol()_h.u53ox2ia3cc: undefined,
      Symbol(observable)_k.u53ox2ia3cc: undefined,
      Symbol(react.element)_g.u53ox2ia3cc: undefined,
      Symbol(Symbol.asyncIterator)_i.u53ox2ia3cc: undefined,
      Symbol(Symbol.observable)_j.u53ox2ia3cc: undefined
   }

Note. If I remove the polyfil then shaka works.

Please let me know if I can help in any way, provide more / clearer details etc.

archived external

Most helpful comment

Good find. Thanks! @bengeorge, does this help?

All 9 comments

Shaka Player has its own promise polyfill, which is installed by shaka.poyfill.installAll() if window.Promise isn't defined. Does the problem still happen if you don't import the core-js promise polyfill?

Does the problem still happen if you don't import the core-js promise polyfill?

Yes this still holds true 馃憤 "Note. If I remove the polyfil then shaka works."

Is it possible that shaka is actually polyfilling more than just promise in promise.js ? I'm not overly familiar with the promise spec but I'll take a look at https://github.com/google/shaka-player/blob/adb8da4764e3080693252ba0211cd4f936fa27be/lib/polyfill/promise.js

Ah, I didn't see that you had addressed that already. My apologies.

Anyway... I'm looking at es6.promise.js, and it looks like their implementation of Promise.all assumes that promises conform to the iterable protocol. We don't use that protocol, to reduce the number of polyfills we need to maintain.
So maybe it's using our implementation of promises, but core-js has overwritten our implementation of Promise.all? I'll look into it further when I have the spare time.

In case anyone else finds same issue: our temp fix is to just use the shaka polyfil instead of core-js 馃槄

// There are issues with core-js promise polyfil and shaka in IE11.
// For now we will rely on shaka promise polyfil.
// See: https://github.com/google/shaka-player/issues/1062
// import 'core-js/modules/es6.promise';

import { polyfill } from 'shaka-player';

polyfill.installAll();

Okay, I've done more testing, and I think this might just be a bug with core-js.
I tried loading only the core-js promise module into a browser, without Shaka Player, and typed
Promise.all([Promise.resolve()])
into the IE browser console, and it threw an exception about [object Object] not being iterable.

@theodab, thanks for looking into this. Can you please file a bug on core-js? https://github.com/zloirock/core-js/issues/new

In that bug, please mention google/shaka-player#1062 to link back here for context, and mention @bengeorge and myself. Thanks!

Looking at core-js's github page, it seems this might be a case of using core-js improperly.
See this and this issue. They warn against using files in core-js/modules/*, as they are internal and not meant to be directly linked unless you really know what you are doing. Instead, they say to include core-js/fn/promise if you want promises.

Good find. Thanks! @bengeorge, does this help?

import 'core-js/fn/promise'; works perfectly 馃憤

@joeyparrish @theodab You guys are awesome. Thanks a bunch for looking into that!

And sorry for wasting your time 馃槄 I should have never doubted shaka!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EstebanBP picture EstebanBP  路  4Comments

interpegasus picture interpegasus  路  3Comments

mateon01 picture mateon01  路  3Comments

dakom picture dakom  路  3Comments

diogoazevedos picture diogoazevedos  路  5Comments