Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Issue 1833303002: [Not committed] Make image load completion async and remove EventSender from ImageLoader (Closed)

Created:
4 years, 9 months ago by hiroshige
Modified:
3 years, 7 months ago
Reviewers:
Nate Chapin
CC:
chromium-reviews, blink-reviews, loading-reviews_chromium.org, tyoshino+watch_chromium.org, Nate Chapin, gavinp+loader_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@Loader_asyncImageLoadEvent_1
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Make image load completion async and remove EventSender from ImageLoader New attempt -> https://codereview.chromium.org/2863763003/ Previously, ImageLoader::notifyFinished() is the point of image completion: i.e. after that point, - |img.complete| is true (and thus we can draw the image on a canvas), - <img>'s load event can be dispatched, and - the image loading no longer blocks document's load event. This CL moves the point to ImageLoader::finish(), which is called asynchronously from ImageLoader::notifyFinished(), by adding an IncrementLoadEventDelayCount that blocks document load event between ImageLoader::notifyFinished() and ImageLoader::finish(). This CL - Fix Issue 382170. The problem was that |img.complete| becomes true before font (data URL) subresource loading of a SVG completes. A subsequent CL [1] will start font subresource loading in SVGImage::dataChanged(), which is called before ImageLoader::notifyFinished() in successful loading, and thus asynchronous data URL loading is completed before ImageLoader::finish() and thus before |img.complete| becomes true. [1] https://codereview.chromium.org/1832333003/ - Remove EventSender singletons in ImageLoader. loadEventSender()/errorEventSender() are singletons shared among all ResourceFetchers, and they cause causality between image/document's load event timing between different ResourceFetcher. This CL replaces EventSenders with CancellableTasks per ImageLoader. Observable behavior changes (catched by newly added loading/onload/ tests) are: - Whether |img.complete| becomes true synchronously when setting |img.src|: For cached images: Previous Chromium: Yes / Firefox: Yes / This CL: No (e.g. images with the same URL is loaded multiple times in a page) For data URLs: Previous Chromium: Yes / Firefox: No / This CL: No This change causes changes in the layout tests in this CL. - Whether starting loading a new image in another image's load event blocks document's load event that would be dispatched otherwise: Previous Chromium: No / Firefox: Yes / This CL: Yes BUG=382170

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Patch Set 4 : #

Patch Set 5 : #

Patch Set 6 : Rebase #

Patch Set 7 : Fix webkit_unit_tests #

Patch Set 8 : Fix fast/images/destroyed-image-load-event.html. #

Patch Set 9 : Fix multipart tests. #

Patch Set 10 : Fix crashes. #

Patch Set 11 : Fix layout tets. #

Patch Set 12 : #

Patch Set 13 : cleanup, fix new layout tests #

Total comments: 8

Patch Set 14 : Rebase. #

Patch Set 15 : Rebase. #

Patch Set 16 : Reflect comments #

Patch Set 17 : #

Patch Set 18 : #

Patch Set 19 : Rebase. #

Patch Set 20 : Add if() statement in cancelPendingFinish() #

Patch Set 21 : Rebase. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+423 lines, -184 lines) Patch
M third_party/WebKit/LayoutTests/fast/canvas/canvas-drawImage-out-of-bounds-src.html View 1 2 3 2 chunks +12 lines, -9 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/loading/onload/onload-image-data-png.html View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +14 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/loading/onload/onload-image-data-png-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +30 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/loading/onload/onload-image-data-svg.html View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +15 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/loading/onload/onload-image-data-svg-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +30 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/loading/onload/onload-image-png.html View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +14 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/loading/onload/onload-image-png-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +30 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/loading/onload/onload-image-svg.html View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +14 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/loading/onload/onload-image-svg-expected.txt View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +30 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/loading/onload/resources/onload-test.js View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +50 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/http/tests/loading/resources/preload-img-test-iframe.html View 1 2 3 4 1 chunk +5 lines, -0 lines 0 comments Download
M third_party/WebKit/LayoutTests/svg/canvas/canvas-draw-image-globalalpha.html View 1 2 3 1 chunk +6 lines, -3 lines 0 comments Download
M third_party/WebKit/LayoutTests/svg/canvas/canvas-draw-image-svg-fragment.html View 1 2 3 1 chunk +14 lines, -4 lines 0 comments Download
M third_party/WebKit/LayoutTests/svg/canvas/canvas-draw-pattern-svg-fragment.html View 1 2 3 2 chunks +17 lines, -5 lines 0 comments Download
M third_party/WebKit/LayoutTests/svg/canvas/image-svg-intrinsic-size.html View 1 2 3 1 chunk +8 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/core/dom/Document.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +0 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLImageLoader.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLImageLoader.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +3 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/core/loader/ImageLoader.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 4 chunks +25 lines, -19 lines 0 comments Download
M third_party/WebKit/Source/core/loader/ImageLoader.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 16 chunks +100 lines, -128 lines 0 comments Download
M third_party/WebKit/Source/web/tests/sim/SimRequest.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 2 chunks +4 lines, -0 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 77 (41 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/1
4 years, 9 months ago (2016-03-25 22:34:50 UTC) #2
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_blink_oilpan_rel on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_blink_oilpan_rel/builds/21948)
4 years, 9 months ago (2016-03-25 22:50:35 UTC) #4
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/20001
4 years, 9 months ago (2016-03-25 23:13:18 UTC) #6
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_blink_oilpan_rel on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_blink_oilpan_rel/builds/21988)
4 years, 9 months ago (2016-03-25 23:33:51 UTC) #8
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/40001
4 years, 9 months ago (2016-03-26 00:42:52 UTC) #10
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_blink_oilpan_rel on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_blink_oilpan_rel/builds/22022)
4 years, 9 months ago (2016-03-26 00:58:24 UTC) #12
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/60001
4 years, 8 months ago (2016-03-28 21:28:54 UTC) #14
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/80001
4 years, 8 months ago (2016-03-28 21:30:37 UTC) #16
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: ios_rel_device_gn on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios_rel_device_gn/builds/9989) ios_rel_device_ninja on ...
4 years, 8 months ago (2016-03-28 21:33:13 UTC) #18
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/100001
4 years, 8 months ago (2016-03-28 21:45:43 UTC) #20
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_chromium_asan_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_asan_rel_ng/builds/136588)
4 years, 8 months ago (2016-03-28 22:37:07 UTC) #23
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/120001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/120001
4 years, 8 months ago (2016-03-28 22:45:20 UTC) #25
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: win_chromium_rel_ng on tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_chromium_rel_ng/builds/195187)
4 years, 8 months ago (2016-03-28 23:48:13 UTC) #27
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/140001
4 years, 8 months ago (2016-03-29 00:59:12 UTC) #29
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/160001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/160001
4 years, 8 months ago (2016-03-29 01:14:32 UTC) #31
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_blink_oilpan_rel on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_blink_oilpan_rel/builds/22520)
4 years, 8 months ago (2016-03-29 02:23:08 UTC) #34
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/200001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/200001
4 years, 8 months ago (2016-03-29 03:23:19 UTC) #36
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/220001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/220001
4 years, 8 months ago (2016-03-29 03:33:18 UTC) #38
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/202992)
4 years, 8 months ago (2016-03-29 04:35:53 UTC) #40
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/240001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/240001
4 years, 8 months ago (2016-03-29 17:21:20 UTC) #42
hiroshige
Nate, what do you think of this?
4 years, 8 months ago (2016-03-29 18:32:35 UTC) #46
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_blink_oilpan_rel on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_blink_oilpan_rel/builds/22808)
4 years, 8 months ago (2016-03-29 18:35:21 UTC) #49
Nate Chapin
This seems reasonable. https://codereview.chromium.org/1833303002/diff/240001/third_party/WebKit/Source/core/loader/ImageLoader.cpp File third_party/WebKit/Source/core/loader/ImageLoader.cpp (right): https://codereview.chromium.org/1833303002/diff/240001/third_party/WebKit/Source/core/loader/ImageLoader.cpp#newcode172 third_party/WebKit/Source/core/loader/ImageLoader.cpp:172: if (m_loadDelayCounterForError) { Why does this ...
4 years, 8 months ago (2016-03-29 19:04:13 UTC) #50
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/260001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/260001
4 years, 8 months ago (2016-03-29 19:20:58 UTC) #52
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/280001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/280001
4 years, 8 months ago (2016-03-29 19:44:02 UTC) #54
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_blink_oilpan_rel on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_blink_oilpan_rel/builds/22922)
4 years, 8 months ago (2016-03-29 20:56:42 UTC) #56
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/300001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/300001
4 years, 8 months ago (2016-03-29 21:42:20 UTC) #58
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/320001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/320001
4 years, 8 months ago (2016-03-29 21:50:26 UTC) #60
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/340001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/340001
4 years, 8 months ago (2016-03-29 21:52:24 UTC) #62
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_blink_oilpan_rel on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_blink_oilpan_rel/builds/23041)
4 years, 8 months ago (2016-03-29 23:02:37 UTC) #64
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/380001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/380001
4 years, 8 months ago (2016-04-04 02:20:01 UTC) #67
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/206146)
4 years, 8 months ago (2016-04-04 04:37:37 UTC) #69
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/380001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/380001
4 years, 8 months ago (2016-04-04 05:16:07 UTC) #71
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1833303002/400001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1833303002/400001
4 years, 8 months ago (2016-04-04 05:19:31 UTC) #73
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 8 months ago (2016-04-04 06:53:54 UTC) #75
hiroshige
3 years, 7 months ago (2017-05-18 22:13:15 UTC) #76
Closing this old issue, as a new attempt
https://codereview.chromium.org/2863763003/ is being made.

https://codereview.chromium.org/1833303002/diff/240001/third_party/WebKit/Sou...
File third_party/WebKit/Source/core/loader/ImageLoader.cpp (right):

https://codereview.chromium.org/1833303002/diff/240001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/loader/ImageLoader.cpp:172: if
(m_loadDelayCounterForError) {
On 2016/03/29 19:04:13, Nate Chapin wrote:
> Why does this have an if() wrapper, but cancelPendingFinish() doesn't?

|m_loadDelayCounterForError| is non-null only between scheduleErrorEvent() and
its actual dispatching (i.e. while |m_dispatchErrorEventTask| is on flight), so
we can put Line 173-174 into the if statement. I think we can also remove the if
condition at Line 172 safely.
This is inherited e.g. from L224-227 on the left.

As for cancelPendingFinish(), if we place corresponding if statements, then it
would be:
if (m_loadDelayCounterForFinish) {
    // We have to always cancel in-flight async finish() calls, because
    // we always post |m_finishTask| in notifyFinished(), regardless
    // of |m_hasPendingLoadEvent|.
    // |m_loadDelayCounterForFinish| is true only if |m_finishTask| is
    // in-flight.
    m_finishTask->cancel();
    m_loadDelayCounterForFinish.clear();
}
if (m_hasPendingLoadEvent) {
    // This if statement is inherited from e.g. Line 220 on the left.
    // There was |loadEventSender().cancelEvent(this);| on the left, but
    // we no longer need to cancel in-flight load event, because load event
    // is now dispatched synchronously in finish().
    // I removed this if-statement because it doesn't look meaningful now.
    m_hasPendingLoadEvent = false;
}

https://codereview.chromium.org/1833303002/diff/240001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/loader/ImageLoader.cpp:466: void
ImageLoader::scheduleFinish()
On 2016/03/29 19:04:13, Nate Chapin wrote:
> scheduleFinish() is only called once. Inline it in notifyFinished()?

Done.

https://codereview.chromium.org/1833303002/diff/240001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/loader/ImageLoader.cpp:475: ImageResource*
cachedImage = m_image.get();
On 2016/03/29 19:04:13, Nate Chapin wrote:
> cachedImage->imageResource? CachedImage is what ImageResource was called until
> about 2013, and it's confusing to have a new variable with that name.

Done.

https://codereview.chromium.org/1833303002/diff/240001/third_party/WebKit/Sou...
third_party/WebKit/Source/core/loader/ImageLoader.cpp:476: ASSERT(cachedImage);
On 2016/03/29 19:04:13, Nate Chapin wrote:
> The theory is that the calls to cancelPendingFinish() handle all cases where
> m_image might be cleared or modified while waiting for the task to happen?

Yes. I inserted cancelPendingFinish() at Line 412 to make this sure.

I thought ImageLoader can/should also assume |m_image| non-null here, because
- HTMLImageLoader::notifyFinished() in the current code base assumes |m_image|
to be non-null (no null checks)
- ImageLoader::notifyFinished() contains |ASSERT(resource == m_image.get());|,
which implies |m_image| is non-null.

(ImageLoader::notifyFinished() contains null checks for |m_image| though. Can we
remove those null checks?)

Powered by Google App Engine
This is Rietveld 408576698