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

Issue 606796 link

Starred by 0 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: May 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Canvas.toBlob() is slow due to a Javascript spinner animation

Reported by matt.cha...@gmail.com, Apr 26 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.86 Safari/537.36

Steps to reproduce the problem:
1. Go to http://codepen.io/anon/pen/RaYVwr/
2. When the canvas has image data, click the button to invoke .toBlobl()
3. Avoid scrolling, moving the mouse, or any user input

What is the expected behavior?
An alert box should display in an reasonable amount of time (1-3 seconds).

What went wrong?
The callback for .toBlob() is not called in a reasonable amount of time. Moving the mouse pointer will seemingly fix the issue. Sometimes .toBlob() will finish in a reasonable amount of time, in that case just keep clicking the button. On my Mac Pro, the strange behavior will show up after 8 or so invocations.

Did this work before? Yes I believe prior to the async toBlob() changes introduced with version 50

Chrome version: 50.0.2661.86  Channel: stable
OS Version: OS X 10.11.4
Flash Version: Shockwave Flash 21.0 r0

This behavior only seem to happen with the Javascript spinner in place. I am guessing there may be some kind of rendering contention happening?
 
I should mention, when the behavior is exhibited, it isn't clear that the callback will ever be called. As far as I can tell, no progress is being made and toBlob() has stalled completely.

Comment 2 by shrike@chromium.org, Apr 27 2016

Components: Blink>JavaScript
Status: Untriaged (was: Unconfirmed)
I tried this in 50.0.2624.0, which should be a version slightly before the first .toBlob change landed in January (7ef3a3a242885e3ba1bbc9501ea80f20354bca44, on 1/19/2016): the operation never completes, even with mouse jiggling. So it seems that things are working better than before, but not great.

You are correct. My initial report was misrepresenting the history of this problem. I had been using a polyfill (https://github.com/blueimp/JavaScript-Canvas-to-Blob) for .toBlob() in Chrome up until official native support was release. This is not a regression after all. I had simply forgotten about my polyfill and that Chrome did not have native support when filing the bug. However, the issue of the callback not being called reliably still stands.
Cc: durga.behera@chromium.org
Labels: -Type-Bug-Regression M-50 Type-Bug
Owner: shrike@chromium.org
Status: Assigned (was: Untriaged)
Unable to rproduce the issue on Mac 10.11.4 using stable 50.0.2661.86 and the steps mentioned in the orginial report.
shrike@ : Assigning to you as per C#2,Could you please review the attached screen shot and update furhther on this.
606796_Apr_27.mp4
633 KB Download

Comment 5 Deleted

C#4 would not show the issue because the spinner is not visible. I have attached a video of the behavior. Notice in my video that the spinner is visible, and that the callback does not fire until I move the mouse pointer. Otherwise, it would keep spinning for minutes.
606796_showing_issue.mp4
1.4 MB Download

Comment 7 by shrike@chromium.org, Apr 27 2016

Labels: Needs-Feedback
Very strange - I have 50.0.2661.86 installed on my machine and tried it there and saw the problem, which is why I went back to test a version before the blob changes landed. However this morning I am unable to reproduce the problem in 50.0.2661.86 or 52.0.2715.0 Canary.

matt.chambers@, can you see if the bug happens for you in the latest Chrome Canary?

52.0.2718.0 Canary still exhibits the behavior. As noted, the issue is not always reproducible for every toBlob() call. In stable and canary, I've had to click 1 to 8 times before the behavior exhibited itself. The CodePen is the most isolated and reproduceable code I have (even with its randomness).
Also tested with --disable-extensions and --disable-plugins in stable 50.0.2661.86. Behavior is reproducible.
Cc: -durga.behera@chromium.org
Owner: durga.behera@chromium.org
Components: -Blink>JavaScript Blink>Canvas
Cc: xlai@chromium.org
ccing xlai@: could you take a look?

Comment 13 by junov@chromium.org, Apr 28 2016

Cc: -xlai@chromium.org
Owner: xlai@chromium.org
This is most likely an issue with toBlob's asynchronous scheduling policy.

xlia@: I recall you had worked on a timeout mechanism to force immediate completion of the encode in cases where idle period scheduling was not allowing the task to complete in a timely manner. Could we get that code to land?

Comment 14 by xlai@chromium.org, Apr 28 2016

junov@: Yes it was  Issue 583070 . I still have that patch that get reverted because of a restriction of not leaking ActiveDomObjects in unit test.

Comment 15 by xlai@chromium.org, May 4 2016

Labels: -M-50
Status: Fixed (was: Assigned)
The bug was due to a combination of two different issues:

1. A lack of timeout mechanism to force immediate completion of encode
   This has been fixed in  Issue 583070 . Patch lands and now in Chrome Canary. 

2. Idle tasks that canvas.toBlob relies upon sometimes do not fire
   This is an open bug ( Issue 609140 ,  Issue 597006 ) in Blink scheduling. 

But the fix in  Issue 583070  should be enough to get away the problem mentioned here. I just tried running http://codepen.io/anon/pen/RaYVwr/ in latest Canary build in Mac. The problem does not show up after I tried clicking the button 30+ times; sometimes toBlob is slow, but it will eventually execute within 9 seconds. I'll mark this as fixed.

Sign in to add a comment