New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 639690 link

Starred by 7 users

Issue metadata

Status: Verified
Owner:
Last visit > 30 days ago
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

Regression: cross origin attribute not working for non-cached video

Reported by mifli...@gmail.com, Aug 21 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36

Example URL:
https://jsfiddle.net/sv7uoure/4/

Steps to reproduce the problem:
1. Open https://jsfiddle.net/sv7uoure/4/
2. Open Console (in DevTools)
3. Notice errors about tainted canvas even though video with crossorigin attribute. Script couldn't make screenshot from video.

What is the expected behavior?
No errors about tainted canvas. Script could make screenshot from video.

What went wrong?
Sometimes you see in console that there is very little time when canvas is not tainted and with real image from video.
Considering this, maybe this bug caused by additional requests with range.

Did this work before? Yes Definitely worked in Chrome 49, also tested in Chromium 50-51 and it's working

Is it a problem with Flash or HTML5? HTML5

Does this work in other browsers? Yes 

Chrome version: 52.0.2743.116  Channel: stable
OS Version: 10.0
Flash Version: Shockwave Flash 22.0 r0

I tested in Chromium 54.0.2824.2 - bug still exists.
 

Comment 1 by mifli...@gmail.com, Aug 21 2016

This can help to find a reason of bug:
> Sometimes you see in console that there is very little time when canvas is not tainted and with real image from video.
> Considering this, maybe this bug caused by additional requests with range.

Example of the case when "there is very little time when canvas is not tainted and with real image from video":
https://jsfiddle.net/sv7uoure/5/

As you see, when video loading screenshot is empty (size is 8490):
progress 0.726476
success. Size of screenshot: 8490
suspend 0.726476
success. Size of screenshot: 8490

After loading screenshot with real data from video (size is 250074):
timeupdate 0.726476
success. Size of screenshot: 250074
seeked 0.726476
success. Size of screenshot: 250074
loadeddata 0.726476
success. Size of screenshot: 250074
canplay 0.726476
success. Size of screenshot: 250074
canplaythrough 0.726476
success. Size of screenshot: 250074
timeupdate 0.726476
success. Size of screenshot: 250074
progress 0.726476

But after less than one second it becomes tainted:
success. Size of screenshot: 250074
progress 0.726476
success. Size of screenshot: 250074
progress 0.726476
error:  DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
suspend 0.726476
error:  DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

At the same time, Chrome makes about 5 requests with ranges 0-4024439, then 3997696-4024439, 32768-4024439, 65536-4024439, 98304-4024439.

Maybe after finising some of additional requests video mistakenly marked as tainted?
Labels: M-54 OS-Linux OS-Mac
Status: Untriaged (was: Unconfirmed)
Able to reproduce the issue for chrome version 54.0.2836.0 on Windows 7, MAC 10.11.6, Ubuntu 14.04. Issue is a non regression seen from M24 - 24.0.1300.0.

Issue is not observed on FF browser. Untriaging it so that it gets addressed.
Cc: hubbe@chromium.org horo@chromium.org
Components: Blink>Network

Comment 4 by mifli...@gmail.com, Aug 22 2016

> Issue is a non regression seen from M24 - 24.0.1300.0.
It is working for me (no issue) in Chrome 49 and Chromium 49. Screenshot in attachment.
test-49.png
90.4 KB View Download
test-49-2.png
212 KB View Download

Comment 5 by hubbe@chromium.org, Aug 23 2016

Cc: -hubbe@chromium.org
Owner: hubbe@chromium.org
Status: Started (was: Untriaged)

Comment 6 by hubbe@chromium.org, Aug 23 2016

When I run this in debug mode, I get the following error:

[1:1:0823/164557:FATAL:multibuffer_data_source.cc(249)] Check failed: init_cb_.is_null() && reader_.get(). Initialize() must complete before calling HasSingleOrigin()
#0 0x7fe7fd92fdbe base::debug::StackTrace::StackTrace()
#1 0x7fe7fd99631f logging::LogMessage::~LogMessage()
#2 0x7fe7e7b86380 media::MultibufferDataSource::HasSingleOrigin()
#3 0x7fe7e7bc6055 media::WebMediaPlayerImpl::hasSingleSecurityOrigin()
#4 0x7fe7e42bbcc7 blink::HTMLMediaElement::hasSingleSecurityOrigin()
#5 0x7fe7e42af1e0 blink::HTMLMediaElement::isMediaDataCORSSameOrigin()
#6 0x7fe7e43182a8 blink::HTMLVideoElement::wouldTaintOrigin()
#7 0x7fe7e4341258 blink::CanvasRenderingContext::wouldTaintOrigin()
#8 0x7fe7e221ea7b blink::CanvasRenderingContext2D::wouldTaintOrigin()
#9 0x7fe7e2209948 blink::BaseRenderingContext2D::drawImage()
#10 0x7fe7e2209ae7 blink::BaseRenderingContext2D::drawImage()
#11 0x7fe7e28682f9 blink::CanvasRenderingContext2DV8Internal::drawImage2Method()
#12 0x7fe7e2866ecf blink::CanvasRenderingContext2DV8Internal::drawImageMethod()
#13 0x7fe7e2857b75 blink::CanvasRenderingContext2DV8Internal::drawImageMethodCallback()
#14 0x7fe7f397999c v8::internal::FunctionCallbackArguments::Call()
#15 0x7fe7f3a24def v8::internal::(anonymous namespace)::HandleApiCallHelper<>()
#16 0x7fe7f3a23c35 v8::internal::Builtin_Impl_HandleApiCall()
#17 0x7fe7f3a2393e v8::internal::Builtin_HandleApiCall()
#18 0x0fe7fd8063a7 <unknown>


I think we really need to re-design the tait/hassingleorigin call. Since the origin can become tainted at any point, polling it is not going to work very well. Especially not before we've even started the http request.

Perhaps this tainting should be attached to the video frames instead?

Comment 7 by mifli...@gmail.com, Aug 24 2016

> Since the origin can become tainted at any point, polling it is not going to work very well.
If I understand correctly, video can't become tainted "in the middle" if it's loaded with "crossorigin" attribute.

For example if you are loading video with "crossorigin" attribute and there is no "Access-Control-Allow-Origin" in response then video just doesn't loads.
Live example https://jsfiddle.net/sv7uoure/6/ (you can see that video stops loading after "error" event).

Comment 8 by hubbe@chromium.org, Aug 24 2016

That's true, and I still need to figure out what is actually going wrong here.
I was just pointing out that the way we poll the hasSingleSecurityOrigin() is flawed.

Comment 9 by hubbe@chromium.org, Aug 24 2016

Hmm, not sure what's going on yet, the network layer and buffering code all reports a single security origin.

Comment 10 by hubbe@chromium.org, Aug 24 2016

Bug found, fix on the way.

Project Member

Comment 11 by bugdroid1@chromium.org, Aug 25 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5f8b274cdab547c8afff5429110a97d15353c19c

commit 5f8b274cdab547c8afff5429110a97d15353c19c
Author: hubbe <hubbe@chromium.org>
Date: Thu Aug 25 00:28:59 2016

Bugfix for cross-origin check

The code is mistaking a missing reader for an error, but readers are now destroyed and re-created on demand.
Adding a new variable to explicitly track failures fixes the problem.

BUG= 639690 

Review-Url: https://codereview.chromium.org/2271313002
Cr-Commit-Position: refs/heads/master@{#414218}

[modify] https://crrev.com/5f8b274cdab547c8afff5429110a97d15353c19c/media/blink/multibuffer_data_source.cc
[modify] https://crrev.com/5f8b274cdab547c8afff5429110a97d15353c19c/media/blink/multibuffer_data_source.h
[modify] https://crrev.com/5f8b274cdab547c8afff5429110a97d15353c19c/media/blink/multibuffer_data_source_unittest.cc

Comment 12 by mifli...@gmail.com, Aug 25 2016

Thank you for the fast fix :-)
The crash from #6 is still occurring for me even with the patch from comment #11, I have a reproducible test case for it but it's at an internal URL. hubbe@, I'll send you the link separately.
FYI, my test page works normally if I just comment out the failing DCHECK in HasSingleOrigin, but that's of course not suitable as a real fix.

Comment 15 by hubbe@chromium.org, Aug 26 2016

Labels: Merge-Request-53

Comment 16 by hubbe@chromium.org, Aug 26 2016

#6 is really a separate problem and should have it's own bug.

Comment 17 by dimu@chromium.org, Aug 26 2016

Labels: -Merge-Request-53 Merge-Review-53 Hotlist-Merge-Review
[Automated comment] Less than 2 weeks to go before stable on M53, manual review required.
M53 is VERY close to  Stable launch and bar is very high. We can take this change only if it is critical, well baked/verified in Canary and safe to merge. Please confirm. Thank you.

Comment 19 by hubbe@chromium.org, Aug 26 2016

The CL is small, simple and safe. It's been in canary for a day.
I'd say the risk is very low.

I'm not entirely sure how critical it is, as the use case is somewhat rare (video element data readback through a canvas where the video is cross-origin).

Since I don't know how common a use case it is, but the risk is low, I would argue that we should merge the fix instead of risking a lot more bug reports later, but obviously the decision is up to you.


Labels: -Merge-Review-53 Merge-Approved-53
Approving merge to M53 branch 2785 based on comment #19. Please merge ASAP. Merge has to happen before 4:00 PM PT  Monday in order to make into the desktop Stable final build cut.Thank you.
Project Member

Comment 21 by bugdroid1@chromium.org, Aug 26 2016

Labels: -merge-approved-53 merge-merged-2785
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9e81a357b3656f2eed03c9bbfda106eb892d9ae8

commit 9e81a357b3656f2eed03c9bbfda106eb892d9ae8
Author: Fredrik Hubinette <hubbe@google.com>
Date: Fri Aug 26 21:43:15 2016

Cherrypick Bugfix for cross-origin check

The code is mistaking a missing reader for an error, but readers are now destroyed and re-created on demand.
Adding a new variable to explicitly track failures fixes the problem.

Original commit:  https://crrev.com/5f8b274cdab547c8afff5429110a97d15353c19c

BUG= 639690 

Review URL: https://codereview.chromium.org/2283153002 .

Cr-Commit-Position: refs/branch-heads/2785@{#766}
Cr-Branched-From: 68623971be0cfc492a2cb0427d7f478e7b214c24-refs/heads/master@{#403382}

[modify] https://crrev.com/9e81a357b3656f2eed03c9bbfda106eb892d9ae8/media/blink/multibuffer_data_source.cc
[modify] https://crrev.com/9e81a357b3656f2eed03c9bbfda106eb892d9ae8/media/blink/multibuffer_data_source.h
[modify] https://crrev.com/9e81a357b3656f2eed03c9bbfda106eb892d9ae8/media/blink/multibuffer_data_source_unittest.cc

Labels: TE-Verified-54.0.2840.0 TE-Verified-54
Verified this issue on Windows-10, Mac OS 10.11.6 and Ubuntu 14.04 using chrome latest Dev M54-54.0.2840.0 by following steps mentioned in the original comment. No errors are seen under console as mentioned in the comment #1 and all the screenshot displays true as expected. Hence adding TE-Verified label.



639690.mp4
6.5 MB View Download
Labels: TE-Verified-M53 TE-Verified-53.0.2785.89
Verified this issue on Windows-10, Mac OS 10.11.6 and Ubuntu 14.04 using chrome latest Beta M53-53.0.2785.89. As mentioned in the comment #22 no errors are seen under console and all the screenshot displays true as expected. Hence adding TE-Verified label.
Screen Shot 2016-08-31 at 2.22.22 PM.png
278 KB View Download
I have cross verified the fix on Win 7 and compared to current stable channel i.e., 52.0.2743.116 with 53.0.2785.89, there are no error in M53(53.0.2785.89).

Comment 25 by hubbe@chromium.org, Sep 12 2016

Status: Verified (was: Started)

Sign in to add a comment