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

Unknown source and unknown target type in Chrome #102

Closed
mostkamp opened this issue Sep 3, 2015 · 5 comments
Closed

Unknown source and unknown target type in Chrome #102

mostkamp opened this issue Sep 3, 2015 · 5 comments

Comments

@mostkamp
Copy link

mostkamp commented Sep 3, 2015

Hi there!

The following code throws two exceptions in Chrome 44:

this.sourceVideo = $('iframe').contents().find('video');
this.sourceVideo.before('<canvas id="chroma-key-canvas"></canvas>');
this.displayCanvas = $('iframe').contents().find('#chroma-key-canvas');

this.seriouslySource = this.seriously.source(this.sourceVideo[0]); // Exception 1
this.seriouslyTarget = this.seriously.target(this.displayCanvas[0]); // Exception 2

The first one is an "unknown source" exception;
the second one is an "unknwon target" exception.
The code works fine in Firefox 40.

The problem seems to be rooted in seriously.js, line 3729 and 5727:

if (target instanceof HTMLElement && target.tagName === 'CANVAS') { ... }
...
if (video instanceof window.HTMLVideoElement) { ... }

Both instanceof checks return true in Firefox and false in Chrome. As a hotfix, I came up with this idea:

if (!(typeof target.accessKey === 'undefined') && target.tagName === 'CANVAS') { ... }
...
if (!(typeof video.videoHeight === 'undefined')) { ... }

Is this a specific problem or a generic issue with Seriously.js/Chrome/Firefox? Any comments are welcome. Thank you!

@brianchirls
Copy link
Owner

Okay, you're trying to access elements inside an iframe. I suspect instanceof isn't working because HTMLElement and HTMLVideoElement are different constructors in a different window. I'm actually surprised that this works in Firefox.

Your iframe is on the same origin, right?

@brianchirls
Copy link
Owner

Do you have some live code you can share that I can test against?

Why are you checking accessKey in your hotfix?

For reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof#instanceof_and_multiple_context_%28e.g._frames_or_windows%29

@brianchirls
Copy link
Owner

See if that solves your problem.

@mostkamp
Copy link
Author

mostkamp commented Sep 4, 2015

Hey, thanks for the quick response and the marvelous fix, that actually solves the issue!
However, now there is another problem that might either be related or something else:
The chroma key effect seems to be broken in Chrome – but it used to work.
I can see the output (and other chained effects, e.g., cropping are working), but the green is just not replaced. Firefox is fine though.

I can send you the link to our live system in a private message.

mostkamp added a commit to sitcomlab/IPED-Toolkit that referenced this issue Sep 4, 2015
@brianchirls
Copy link
Owner

Okay, great. Can you file the chroma key bug under a separate issue? I'll close this one.

Also, can you make sure you're using the latest version from the develop branch? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants