Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When checking Asynchronous Module Definition availability, look for 'function' type explicitly #2847

Closed
naktinis opened this issue Sep 14, 2020 · 0 comments
Assignees
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@naktinis
Copy link

Have you read the FAQ and checked for duplicate open issues?

Yes.

What version of Shaka Player are you using?

Master.

Can you reproduce the issue with our latest release version?

Yes.

Can you reproduce the issue with the latest code from master?

Yes.

Are you using the demo app or your own custom app?

Own custom app.

If custom app, can you reproduce the issue using our demo app?

N/A.

What browser and OS are you using?

N/A.

For embedded devices (smart TVs, etc.), what model and firmware version are you using?

N/A.

What are the manifest and license server URIs?

N/A.

What did you do?

Include shaka-player.compiled.js.

What did you expect to happen?

No exception should be thrown.

What actually happened?

Shaka is trying to check for "define.amd" of a null object.

shaka.min.js:9 Uncaught TypeError: Cannot read property 'amd' of null
    at shaka.min.js:9
    at shaka.min.js:9

In build/wrapper.template.js there is a line:

  } else if (typeof define != 'undefined' && define.amd) {

However, it happened so that on some websites where shaka is embedded there is a global define object set to null.

I think a better check here would be:

  } else if (typeof define == 'function' && define.amd) {

This would avoid being triggered for define = null. Also, this is what some other libraries are using, e.g.:
https://devhints.io/umdjs
https://github.com/simontabor/jquery-toggles/blob/master/toggles.js#L266
https://github.com/wieringen/tinyscrollbar/blob/master/lib/tinyscrollbar.js#L385

@joeyparrish joeyparrish added type: bug Something isn't working correctly and removed needs triage labels Sep 14, 2020
@joeyparrish joeyparrish added this to the v3.1 milestone Sep 14, 2020
@joeyparrish joeyparrish self-assigned this Sep 14, 2020
matEhickey pushed a commit to matEhickey/shaka-player that referenced this issue Sep 16, 2020
It seems that some websites have a global "define" object set to null.
This caused our module loader to break when Shaka Player was loaded.

By checking for "define" to have a "function" type, rather than just
being defined at all, we can avoid this problem.

Closes shaka-project#2847

Change-Id: I645f61687b9ec298bcc51c8d128398cdad3dd3b9
matEhickey pushed a commit to matEhickey/shaka-player that referenced this issue Sep 25, 2020
It seems that some websites have a global "define" object set to null.
This caused our module loader to break when Shaka Player was loaded.

By checking for "define" to have a "function" type, rather than just
being defined at all, we can avoid this problem.

Closes shaka-project#2847

Change-Id: I645f61687b9ec298bcc51c8d128398cdad3dd3b9
matEhickey pushed a commit to matEhickey/shaka-player that referenced this issue Sep 25, 2020
It seems that some websites have a global "define" object set to null.
This caused our module loader to break when Shaka Player was loaded.

By checking for "define" to have a "function" type, rather than just
being defined at all, we can avoid this problem.

Closes shaka-project#2847

Change-Id: I645f61687b9ec298bcc51c8d128398cdad3dd3b9
joeyparrish added a commit that referenced this issue Sep 29, 2020
It seems that some websites have a global "define" object set to null.
This caused our module loader to break when Shaka Player was loaded.

By checking for "define" to have a "function" type, rather than just
being defined at all, we can avoid this problem.

Closes #2847

Change-Id: I645f61687b9ec298bcc51c8d128398cdad3dd3b9
joeyparrish added a commit that referenced this issue Oct 1, 2020
It seems that some websites have a global "define" object set to null.
This caused our module loader to break when Shaka Player was loaded.

By checking for "define" to have a "function" type, rather than just
being defined at all, we can avoid this problem.

Closes #2847

Change-Id: I645f61687b9ec298bcc51c8d128398cdad3dd3b9
@shaka-project shaka-project locked and limited conversation to collaborators Nov 14, 2020
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

3 participants