Preserve lazy loading behavior when an image is side-loaded [chromium/src : main]

0 views
Skip to first unread message

Stefan Zager (Gerrit)

unread,
Dec 12, 2025, 2:43:13 PM (4 days ago) Dec 12
to Philip Rogers, Menard, Alexis, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
Attention needed from Philip Rogers

Stefan Zager added 1 comment

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Stefan Zager . resolved

pdr, can you review this? dom@ has absconded.

Open in Gerrit

Related details

Attention is currently required from:
  • Philip Rogers
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
Gerrit-Change-Number: 7240346
Gerrit-PatchSet: 3
Gerrit-Owner: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Philip Rogers <p...@chromium.org>
Gerrit-Comment-Date: Fri, 12 Dec 2025 19:43:04 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Philip Rogers (Gerrit)

unread,
Dec 12, 2025, 4:45:30 PM (4 days ago) Dec 12
to Stefan Zager, Menard, Alexis, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
Attention needed from Stefan Zager

Philip Rogers added 3 comments

Commit Message
Line 8, Patchset 3 (Latest):
Philip Rogers . unresolved

Can you add a few lines about the high-level change?

Line 8, Patchset 3 (Latest):
Philip Rogers . unresolved

Safari has the same behavior as us, so there is a chance that sites are relying on our current behavior. Can you put this behind an enabled-by-default runtime enabled flag just in case?

File third_party/blink/renderer/core/loader/image_loader.cc
Line 416, Patchset 3 (Latest): EnqueueImageLoadingMicroTask(kUpdateFromMicrotask);
Philip Rogers . unresolved

I think we still need to call stop monitoring here and in ElementStyleResources::LoadPendingImages for the following scenario:

1. pre-load cached image a.png
2. new image element with lazy and src=b.png and offscreen, starts monitoring
3. switch new image element src to a.png
4. no call to stop monitoring.

Open in Gerrit

Related details

Attention is currently required from:
  • Stefan Zager
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
    Gerrit-Change-Number: 7240346
    Gerrit-PatchSet: 3
    Gerrit-Owner: Stefan Zager <sza...@chromium.org>
    Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
    Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Stefan Zager <sza...@chromium.org>
    Gerrit-Comment-Date: Fri, 12 Dec 2025 21:45:21 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Stefan Zager (Gerrit)

    unread,
    Dec 12, 2025, 5:11:20 PM (4 days ago) Dec 12
    to Philip Rogers, Menard, Alexis, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
    Attention needed from Philip Rogers

    Stefan Zager added 3 comments

    Commit Message
    Line 8, Patchset 3:
    Philip Rogers . resolved

    Safari has the same behavior as us, so there is a chance that sites are relying on our current behavior. Can you put this behind an enabled-by-default runtime enabled flag just in case?

    Stefan Zager

    Done

    Line 8, Patchset 3:
    Philip Rogers . resolved

    Can you add a few lines about the high-level change?

    Stefan Zager

    Done

    File third_party/blink/renderer/core/loader/image_loader.cc
    Line 416, Patchset 3: EnqueueImageLoadingMicroTask(kUpdateFromMicrotask);
    Philip Rogers . resolved

    I think we still need to call stop monitoring here and in ElementStyleResources::LoadPendingImages for the following scenario:

    1. pre-load cached image a.png
    2. new image element with lazy and src=b.png and offscreen, starts monitoring
    3. switch new image element src to a.png
    4. no call to stop monitoring.

    Stefan Zager

    I didn't remove a call to `StopMonitoring()` here or in ElementStyleResources. I think you are referring to the call I removed below in `ImageLoader::ImageNotifyFinished()`. That one needs to be removed, to ensure the `load` event is properly triggered when the image enters the viewport.

    If you think there should be a call to `StopMonitoring()` here and/or in ElementStyleResources, then I think there should be a separate bug and separate CL.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Philip Rogers
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
      Gerrit-Change-Number: 7240346
      Gerrit-PatchSet: 4
      Gerrit-Owner: Stefan Zager <sza...@chromium.org>
      Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
      Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
      Gerrit-CC: Menard, Alexis <alexis...@intel.com>
      Gerrit-CC: Nate Chapin <jap...@chromium.org>
      Gerrit-Attention: Philip Rogers <p...@chromium.org>
      Gerrit-Comment-Date: Fri, 12 Dec 2025 22:11:10 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Philip Rogers <p...@chromium.org>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Stefan Zager (Gerrit)

      unread,
      Dec 12, 2025, 6:25:56 PM (4 days ago) Dec 12
      to Philip Rogers, Menard, Alexis, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, kinuko...@chromium.org, jmedle...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
      Attention needed from Philip Rogers

      Stefan Zager added 1 comment

      File third_party/blink/renderer/core/loader/image_loader.cc
      Line 416, Patchset 3: EnqueueImageLoadingMicroTask(kUpdateFromMicrotask);
      Philip Rogers . unresolved

      I think we still need to call stop monitoring here and in ElementStyleResources::LoadPendingImages for the following scenario:

      1. pre-load cached image a.png
      2. new image element with lazy and src=b.png and offscreen, starts monitoring
      3. switch new image element src to a.png
      4. no call to stop monitoring.

      Stefan Zager

      I didn't remove a call to `StopMonitoring()` here or in ElementStyleResources. I think you are referring to the call I removed below in `ImageLoader::ImageNotifyFinished()`. That one needs to be removed, to ensure the `load` event is properly triggered when the image enters the viewport.

      If you think there should be a call to `StopMonitoring()` here and/or in ElementStyleResources, then I think there should be a separate bug and separate CL.

      Stefan Zager

      Oh, I think I see what you mean. I'll add the calls to `StopMonitoring()`, can't hurt anyways.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Philip Rogers
      Submit Requirements:
        • requirement satisfiedCode-Coverage
        • requirement satisfiedCode-Owners
        • requirement is not satisfiedCode-Review
        • requirement is not satisfiedNo-Unresolved-Comments
        • requirement is not satisfiedReview-Enforcement
        Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
        Gerrit-MessageType: comment
        Gerrit-Project: chromium/src
        Gerrit-Branch: main
        Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
        Gerrit-Change-Number: 7240346
        Gerrit-PatchSet: 5
        Gerrit-Owner: Stefan Zager <sza...@chromium.org>
        Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
        Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
        Gerrit-CC: Menard, Alexis <alexis...@intel.com>
        Gerrit-CC: Nate Chapin <jap...@chromium.org>
        Gerrit-Attention: Philip Rogers <p...@chromium.org>
        Gerrit-Comment-Date: Fri, 12 Dec 2025 23:25:45 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Comment-In-Reply-To: Stefan Zager <sza...@chromium.org>
        Comment-In-Reply-To: Philip Rogers <p...@chromium.org>
        satisfied_requirement
        unsatisfied_requirement
        open
        diffy

        Stefan Zager (Gerrit)

        unread,
        Dec 12, 2025, 6:30:16 PM (4 days ago) Dec 12
        to Philip Rogers, Menard, Alexis, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, kinuko...@chromium.org, jmedle...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
        Attention needed from Philip Rogers

        Stefan Zager added 1 comment

        File third_party/blink/renderer/core/loader/image_loader.cc
        Line 416, Patchset 3: EnqueueImageLoadingMicroTask(kUpdateFromMicrotask);
        Philip Rogers . resolved

        I think we still need to call stop monitoring here and in ElementStyleResources::LoadPendingImages for the following scenario:

        1. pre-load cached image a.png
        2. new image element with lazy and src=b.png and offscreen, starts monitoring
        3. switch new image element src to a.png
        4. no call to stop monitoring.

        Stefan Zager

        I didn't remove a call to `StopMonitoring()` here or in ElementStyleResources. I think you are referring to the call I removed below in `ImageLoader::ImageNotifyFinished()`. That one needs to be removed, to ensure the `load` event is properly triggered when the image enters the viewport.

        If you think there should be a call to `StopMonitoring()` here and/or in ElementStyleResources, then I think there should be a separate bug and separate CL.

        Stefan Zager

        Oh, I think I see what you mean. I'll add the calls to `StopMonitoring()`, can't hurt anyways.

        Stefan Zager

        Done

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Philip Rogers
        Submit Requirements:
          • requirement satisfiedCode-Coverage
          • requirement satisfiedCode-Owners
          • requirement is not satisfiedCode-Review
          • requirement is not satisfiedReview-Enforcement
          Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
          Gerrit-MessageType: comment
          Gerrit-Project: chromium/src
          Gerrit-Branch: main
          Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
          Gerrit-Change-Number: 7240346
          Gerrit-PatchSet: 6
          Gerrit-Owner: Stefan Zager <sza...@chromium.org>
          Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
          Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
          Gerrit-CC: Menard, Alexis <alexis...@intel.com>
          Gerrit-CC: Nate Chapin <jap...@chromium.org>
          Gerrit-Attention: Philip Rogers <p...@chromium.org>
          Gerrit-Comment-Date: Fri, 12 Dec 2025 23:30:07 +0000
          satisfied_requirement
          unsatisfied_requirement
          open
          diffy

          Philip Rogers (Gerrit)

          unread,
          Dec 12, 2025, 6:55:35 PM (4 days ago) Dec 12
          to Stefan Zager, Menard, Alexis, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, kinuko...@chromium.org, jmedle...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
          Attention needed from Stefan Zager

          Philip Rogers voted and added 1 comment

          Votes added by Philip Rogers

          Code-Review+1

          1 comment

          File third_party/blink/renderer/core/loader/image_loader.cc
          Line 416, Patchset 3: EnqueueImageLoadingMicroTask(kUpdateFromMicrotask);
          Philip Rogers . resolved

          I think we still need to call stop monitoring here and in ElementStyleResources::LoadPendingImages for the following scenario:

          1. pre-load cached image a.png
          2. new image element with lazy and src=b.png and offscreen, starts monitoring
          3. switch new image element src to a.png
          4. no call to stop monitoring.

          Stefan Zager

          I didn't remove a call to `StopMonitoring()` here or in ElementStyleResources. I think you are referring to the call I removed below in `ImageLoader::ImageNotifyFinished()`. That one needs to be removed, to ensure the `load` event is properly triggered when the image enters the viewport.

          If you think there should be a call to `StopMonitoring()` here and/or in ElementStyleResources, then I think there should be a separate bug and separate CL.

          Stefan Zager

          Oh, I think I see what you mean. I'll add the calls to `StopMonitoring()`, can't hurt anyways.

          Stefan Zager

          Done

          Philip Rogers

          Thanks! LGTM with the fix you applied in your latest patchset (it fixes a local test I have).

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Stefan Zager
          Submit Requirements:
            • requirement satisfiedCode-Coverage
            • requirement satisfiedCode-Owners
            • requirement satisfiedCode-Review
            • requirement satisfiedReview-Enforcement
            Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
            Gerrit-MessageType: comment
            Gerrit-Project: chromium/src
            Gerrit-Branch: main
            Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
            Gerrit-Change-Number: 7240346
            Gerrit-PatchSet: 6
            Gerrit-Owner: Stefan Zager <sza...@chromium.org>
            Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
            Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
            Gerrit-CC: Menard, Alexis <alexis...@intel.com>
            Gerrit-CC: Nate Chapin <jap...@chromium.org>
            Gerrit-Attention: Stefan Zager <sza...@chromium.org>
            Gerrit-Comment-Date: Fri, 12 Dec 2025 23:55:23 +0000
            Gerrit-HasComments: Yes
            Gerrit-Has-Labels: Yes
            satisfied_requirement
            open
            diffy

            Philip Rogers (Gerrit)

            unread,
            Dec 12, 2025, 6:59:25 PM (4 days ago) Dec 12
            to Stefan Zager, Menard, Alexis, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, kinuko...@chromium.org, jmedle...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
            Attention needed from Stefan Zager

            Philip Rogers added 1 comment

            File third_party/blink/renderer/core/css/resolver/element_style_resources.cc
            Line 439, Patchset 6 (Latest): LazyImageHelper::StopMonitoring(GetElement());
            Philip Rogers . unresolved
            ```suggestion
            LazyImageHelper::StopMonitoring(&element_);
            ```
            Open in Gerrit

            Related details

            Attention is currently required from:
            • Stefan Zager
            Submit Requirements:
              • requirement satisfiedCode-Coverage
              • requirement satisfiedCode-Owners
              • requirement satisfiedCode-Review
              • requirement is not satisfiedNo-Unresolved-Comments
              • requirement satisfiedReview-Enforcement
              Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
              Gerrit-MessageType: comment
              Gerrit-Project: chromium/src
              Gerrit-Branch: main
              Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
              Gerrit-Change-Number: 7240346
              Gerrit-PatchSet: 6
              Gerrit-Owner: Stefan Zager <sza...@chromium.org>
              Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
              Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
              Gerrit-CC: Menard, Alexis <alexis...@intel.com>
              Gerrit-CC: Nate Chapin <jap...@chromium.org>
              Gerrit-Attention: Stefan Zager <sza...@chromium.org>
              Gerrit-Comment-Date: Fri, 12 Dec 2025 23:59:15 +0000
              Gerrit-HasComments: Yes
              Gerrit-Has-Labels: No
              satisfied_requirement
              unsatisfied_requirement
              open
              diffy

              Stefan Zager (Gerrit)

              unread,
              Dec 13, 2025, 11:32:56 AM (3 days ago) Dec 13
              to Philip Rogers, Menard, Alexis, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, kinuko...@chromium.org, jmedle...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org

              Stefan Zager added 1 comment

              File third_party/blink/renderer/core/css/resolver/element_style_resources.cc
              Line 439, Patchset 6: LazyImageHelper::StopMonitoring(GetElement());
              Philip Rogers . resolved
              ```suggestion
              LazyImageHelper::StopMonitoring(&element_);
              ```
              Stefan Zager

              Done

              Open in Gerrit

              Related details

              Attention set is empty
              Submit Requirements:
                • requirement satisfiedCode-Coverage
                • requirement satisfiedCode-Owners
                • requirement satisfiedCode-Review
                • requirement satisfiedReview-Enforcement
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: chromium/src
                Gerrit-Branch: main
                Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
                Gerrit-Change-Number: 7240346
                Gerrit-PatchSet: 7
                Gerrit-Owner: Stefan Zager <sza...@chromium.org>
                Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
                Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
                Gerrit-CC: Menard, Alexis <alexis...@intel.com>
                Gerrit-CC: Nate Chapin <jap...@chromium.org>
                Gerrit-Comment-Date: Sat, 13 Dec 2025 16:32:43 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                Comment-In-Reply-To: Philip Rogers <p...@chromium.org>
                satisfied_requirement
                open
                diffy

                Stefan Zager (Gerrit)

                unread,
                Dec 13, 2025, 11:33:03 AM (3 days ago) Dec 13
                to Philip Rogers, Menard, Alexis, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, kinuko...@chromium.org, jmedle...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org

                Stefan Zager voted Commit-Queue+2

                Commit-Queue+2
                Open in Gerrit

                Related details

                Attention set is empty
                Submit Requirements:
                • requirement satisfiedCode-Coverage
                • requirement satisfiedCode-Owners
                • requirement satisfiedCode-Review
                • requirement satisfiedReview-Enforcement
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: chromium/src
                Gerrit-Branch: main
                Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
                Gerrit-Change-Number: 7240346
                Gerrit-PatchSet: 7
                Gerrit-Owner: Stefan Zager <sza...@chromium.org>
                Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
                Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
                Gerrit-CC: Menard, Alexis <alexis...@intel.com>
                Gerrit-CC: Nate Chapin <jap...@chromium.org>
                Gerrit-Comment-Date: Sat, 13 Dec 2025 16:32:51 +0000
                Gerrit-HasComments: No
                Gerrit-Has-Labels: Yes
                satisfied_requirement
                open
                diffy

                Chromium LUCI CQ (Gerrit)

                unread,
                Dec 13, 2025, 2:36:55 PM (3 days ago) Dec 13
                to Stefan Zager, Philip Rogers, Menard, Alexis, AyeAye, chromium...@chromium.org, Nate Chapin, kinuko...@chromium.org, jmedle...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org

                Chromium LUCI CQ submitted the change with unreviewed changes

                Unreviewed changes

                6 is the latest approved patch-set.
                The change was submitted with unreviewed changes in the following files:

                ```
                The name of the file: third_party/blink/renderer/core/css/resolver/element_style_resources.cc
                Insertions: 1, Deletions: 1.

                @@ -436,7 +436,7 @@
                if (new_image->IsLoaded() &&
                RuntimeEnabledFeatures::
                LazyImageConformantLoadEventTimingEnabled()) {
                - LazyImageHelper::StopMonitoring(GetElement());
                + LazyImageHelper::StopMonitoring(&element_);
                To<StyleFetchedImage>(new_image)->LoadDeferredImage(
                element_.GetDocument());
                } else {
                ```

                Change information

                Commit message:
                Preserve lazy loading behavior when an image is side-loaded

                According to the spec, if the resource for an <img loading="lazy"> is
                loaded via other means (e.g. fetch()), then the <img> should not
                fire its load event until it enters the viewport.

                Putting this behind a flag in case sites are relying on the legacy
                broken behavior.
                Bug: 375209498
                Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
                Commit-Queue: Stefan Zager <sza...@chromium.org>
                Reviewed-by: Philip Rogers <p...@chromium.org>
                Cr-Commit-Position: refs/heads/main@{#1558440}
                Files:
                • M third_party/blink/renderer/core/css/resolver/element_style_resources.cc
                • M third_party/blink/renderer/core/loader/image_loader.cc
                • M third_party/blink/renderer/platform/runtime_enabled_features.json5
                • D third_party/blink/web_tests/external/wpt/html/semantics/embedded-content/the-img-element/update-the-image-data/lazy-out-of-band-load-expected.txt
                Change size: M
                Delta: 4 files changed, 33 insertions(+), 18 deletions(-)
                Branch: refs/heads/main
                Submit Requirements:
                • requirement satisfiedCode-Review: +1 by Philip Rogers
                Open in Gerrit
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: merged
                Gerrit-Project: chromium/src
                Gerrit-Branch: main
                Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
                Gerrit-Change-Number: 7240346
                Gerrit-PatchSet: 8
                Gerrit-Owner: Stefan Zager <sza...@chromium.org>
                Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
                Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
                Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
                open
                diffy
                satisfied_requirement

                Dominic Farolino (Gerrit)

                unread,
                Dec 14, 2025, 9:33:51 PM (2 days ago) Dec 14
                to Chromium LUCI CQ, Stefan Zager, Philip Rogers, Menard, Alexis, AyeAye, chromium...@chromium.org, Nate Chapin, kinuko...@chromium.org, jmedle...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
                Attention needed from Stefan Zager

                Dominic Farolino added 2 comments

                Patchset-level comments
                File-level comment, Patchset 8 (Latest):
                Dominic Farolino . resolved

                I realize this is landed. But after OOO I saw a message about this from Stephan decided to take a look.

                Commit Message
                Line 9, Patchset 8 (Latest):According to the spec, if the resource for an <img loading="lazy"> is
                Dominic Farolino . unresolved

                Where in the spec? I believe the document's list of available images is consulted before lazy-load-ness is evaluated, in https://html.spec.whatwg.org/#updating-the-image-data.

                Either way, I think the set-up described here is ambiguous. I can think of two different things that it could mean:

                1. First create a loading=lazy image that's out-of-viewport, and while it's paused, fetch the same resource via `fetch()` or some other means, and observe that the loading=lazy img element does NOT get its load event fired;
                2. First load some resource via `fetch()` or an eager img tag. Sometime later, create a loading=lazy image and note that it does not load immediately, despite its resource being in the document's list of available images cache.

                I was hoping looking at the test would clear up which scenario we were referring to, but [the test](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/external/wpt/html/semantics/embedded-content/the-img-element/update-the-image-data/lazy-out-of-band-load.html) appears to be testing NEITHER of these scenarios. Am I correct? It looks like it's trying to test (2), but I'm not sure it's doing it right.

                (I think the inverse of (2) above should happen, per spec).

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Stefan Zager
                Submit Requirements:
                • requirement satisfiedCode-Coverage
                • requirement satisfiedCode-Owners
                • requirement satisfiedCode-Review
                • requirement satisfiedReview-Enforcement
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: chromium/src
                Gerrit-Branch: main
                Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
                Gerrit-Change-Number: 7240346
                Gerrit-PatchSet: 8
                Gerrit-Owner: Stefan Zager <sza...@chromium.org>
                Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
                Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
                Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
                Gerrit-CC: Dominic Farolino <d...@chromium.org>
                Gerrit-CC: Menard, Alexis <alexis...@intel.com>
                Gerrit-CC: Nate Chapin <jap...@chromium.org>
                Gerrit-Attention: Stefan Zager <sza...@chromium.org>
                Gerrit-Comment-Date: Mon, 15 Dec 2025 02:33:45 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                satisfied_requirement
                open
                diffy

                Stefan Zager (Gerrit)

                unread,
                Dec 15, 2025, 2:33:46 PM (yesterday) Dec 15
                to Chromium LUCI CQ, Dominic Farolino, Philip Rogers, Menard, Alexis, AyeAye, chromium...@chromium.org, Nate Chapin, kinuko...@chromium.org, jmedle...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
                Attention needed from Stefan Zager

                Stefan Zager has created a revert of this change

                Related details

                Attention is currently required from:
                • Stefan Zager
                Submit Requirements:
                • requirement satisfiedCode-Coverage
                • requirement satisfiedCode-Owners
                • requirement satisfiedCode-Review
                • requirement satisfiedReview-Enforcement
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: revert
                satisfied_requirement
                open
                diffy

                Stefan Zager (Gerrit)

                unread,
                Dec 15, 2025, 2:41:47 PM (yesterday) Dec 15
                to Chromium LUCI CQ, Dominic Farolino, Philip Rogers, Menard, Alexis, AyeAye, chromium...@chromium.org, Nate Chapin, kinuko...@chromium.org, jmedle...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org

                Stefan Zager added 1 comment

                Commit Message
                Line 9, Patchset 8 (Latest):According to the spec, if the resource for an <img loading="lazy"> is
                Dominic Farolino . unresolved

                Where in the spec? I believe the document's list of available images is consulted before lazy-load-ness is evaluated, in https://html.spec.whatwg.org/#updating-the-image-data.

                Either way, I think the set-up described here is ambiguous. I can think of two different things that it could mean:

                1. First create a loading=lazy image that's out-of-viewport, and while it's paused, fetch the same resource via `fetch()` or some other means, and observe that the loading=lazy img element does NOT get its load event fired;
                2. First load some resource via `fetch()` or an eager img tag. Sometime later, create a loading=lazy image and note that it does not load immediately, despite its resource being in the document's list of available images cache.

                I was hoping looking at the test would clear up which scenario we were referring to, but [the test](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/external/wpt/html/semantics/embedded-content/the-img-element/update-the-image-data/lazy-out-of-band-load.html) appears to be testing NEITHER of these scenarios. Am I correct? It looks like it's trying to test (2), but I'm not sure it's doing it right.

                (I think the inverse of (2) above should happen, per spec).

                Stefan Zager

                The test is testing (1). The `<img>` under test is not out of viewport but it's `display:none`, which should have the same behavior.

                As for where the spec addresses this specifically: I don't know, I am relying on the conversation on the spec issue that motivated this CL:

                https://github.com/whatwg/html/issues/10671

                Do you think that this CL doesn't correctly implement the behavior described there? Or do you think the discussion on the spec issue misinterprets the spec?

                Open in Gerrit

                Related details

                Attention set is empty
                Submit Requirements:
                • requirement satisfiedCode-Coverage
                • requirement satisfiedCode-Owners
                • requirement satisfiedCode-Review
                • requirement satisfiedReview-Enforcement
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: chromium/src
                Gerrit-Branch: main
                Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
                Gerrit-Change-Number: 7240346
                Gerrit-PatchSet: 8
                Gerrit-Owner: Stefan Zager <sza...@chromium.org>
                Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
                Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
                Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
                Gerrit-CC: Dominic Farolino <d...@chromium.org>
                Gerrit-CC: Menard, Alexis <alexis...@intel.com>
                Gerrit-CC: Nate Chapin <jap...@chromium.org>
                Gerrit-Comment-Date: Mon, 15 Dec 2025 19:41:40 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                Comment-In-Reply-To: Dominic Farolino <d...@chromium.org>
                satisfied_requirement
                open
                diffy

                Dominic Farolino (Gerrit)

                unread,
                5:20 PM (5 hours ago) 5:20 PM
                to Chromium LUCI CQ, Stefan Zager, Philip Rogers, Menard, Alexis, AyeAye, chromium...@chromium.org, Nate Chapin, kinuko...@chromium.org, jmedle...@chromium.org, blink-re...@chromium.org, blink-revie...@chromium.org, apavlo...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
                Attention needed from Stefan Zager

                Dominic Farolino added 1 comment

                Commit Message
                Line 9, Patchset 8 (Latest):According to the spec, if the resource for an <img loading="lazy"> is
                Dominic Farolino . unresolved

                Where in the spec? I believe the document's list of available images is consulted before lazy-load-ness is evaluated, in https://html.spec.whatwg.org/#updating-the-image-data.

                Either way, I think the set-up described here is ambiguous. I can think of two different things that it could mean:

                1. First create a loading=lazy image that's out-of-viewport, and while it's paused, fetch the same resource via `fetch()` or some other means, and observe that the loading=lazy img element does NOT get its load event fired;
                2. First load some resource via `fetch()` or an eager img tag. Sometime later, create a loading=lazy image and note that it does not load immediately, despite its resource being in the document's list of available images cache.

                I was hoping looking at the test would clear up which scenario we were referring to, but [the test](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/web_tests/external/wpt/html/semantics/embedded-content/the-img-element/update-the-image-data/lazy-out-of-band-load.html) appears to be testing NEITHER of these scenarios. Am I correct? It looks like it's trying to test (2), but I'm not sure it's doing it right.

                (I think the inverse of (2) above should happen, per spec).

                Stefan Zager

                The test is testing (1). The `<img>` under test is not out of viewport but it's `display:none`, which should have the same behavior.

                As for where the spec addresses this specifically: I don't know, I am relying on the conversation on the spec issue that motivated this CL:

                https://github.com/whatwg/html/issues/10671

                Do you think that this CL doesn't correctly implement the behavior described there? Or do you think the discussion on the spec issue misinterprets the spec?

                Dominic Farolino

                As for where the spec addresses this specifically: I don't know, I am relying on the conversation on the spec issue that motivated this CL:
                > https://github.com/whatwg/html/issues/10671

                I see, I didn't realize this CL was aimed at fixing Chromium's implementation of that HTML Standard bug. Based on the CL description I was unclear if this was trying to solve (1) or (2) above, thanks, and sorry!

                Looking closer, I do think the test correctly tests that scenario—that a pending lazyload image does not suddenly free up and eagerly load a resource that was side-loaded. It looked funny to me since the test reuses the same variable for both imgs, but it's fine.

                Do you think that this CL doesn't correctly implement the behavior described there?

                This CL tries to get the same observable results as the spec, but the fundamental problem is described in https://github.com/whatwg/html/issues/10671#issuecomment-2450198052, and this CL doesn't "fix" it, but it tries to bypass the bad side-effects of it. What I'm saying is that for `loading=lazy` images, the spec stops the image loading pipeline super early, before it ever reaches the spec-equivalent of blink::ResourceFetcher. Blink has the fundamental problem of pausing/deferring a `loading=lazy` image quite late, in the blink::ResourceFetcher, after the "empty" blink::Resource representing the image has already been registered with the loading infra.

                This is bad because then when an image is side-loaded by a different blink::Resource that happens to "match" the lazy-loaded one and get coalesced into the same one, all registered clients for coalesced blink::Resource get to share the freshly-loaded resource.

                I can envision two solutions to this:

                1. Heavy: refactor the lazy loading infra to defer an image way before blink::ResourceFetcher, so that it's not registered as a blink::Resource and cannot be coalesced into other side-loaded out-of-band resources for the same image.
                2. Light: Modify the [`Resource::CanReuse()`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/loader/fetch/resource.cc;l=793;drc=cf35b90f85d2dc2bfbef0b6950207a8cd81f66d7) logic to somehow discriminate between lazyloaded resources and non-lazy-loaded resources. Maybe we want access to [`image_request_behavior_`](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/loader/fetch/fetch_parameters.h;l=181-183;drc=7666bc1983c2a5b98e5dc6fa6c28f8f53c07d06f). This might already be possible based on the information on blink::Resource , but if not maybe we'll need add a bit somewhere.

                Open in Gerrit

                Related details

                Attention is currently required from:
                • Stefan Zager
                Submit Requirements:
                • requirement satisfiedCode-Coverage
                • requirement satisfiedCode-Owners
                • requirement satisfiedCode-Review
                • requirement satisfiedReview-Enforcement
                Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
                Gerrit-MessageType: comment
                Gerrit-Project: chromium/src
                Gerrit-Branch: main
                Gerrit-Change-Id: I58f47ae1efdb953cdffc642eb68264484d1d20b3
                Gerrit-Change-Number: 7240346
                Gerrit-PatchSet: 8
                Gerrit-Owner: Stefan Zager <sza...@chromium.org>
                Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
                Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
                Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
                Gerrit-CC: Dominic Farolino <d...@chromium.org>
                Gerrit-CC: Menard, Alexis <alexis...@intel.com>
                Gerrit-CC: Nate Chapin <jap...@chromium.org>
                Gerrit-Attention: Stefan Zager <sza...@chromium.org>
                Gerrit-Comment-Date: Tue, 16 Dec 2025 22:20:03 +0000
                Gerrit-HasComments: Yes
                Gerrit-Has-Labels: No
                Comment-In-Reply-To: Dominic Farolino <d...@chromium.org>
                Comment-In-Reply-To: Stefan Zager <sza...@chromium.org>
                satisfied_requirement
                open
                diffy
                Reply all
                Reply to author
                Forward
                0 new messages