Dial in criteria for speculatively decoding images [chromium/src : main]

0 views
Skip to first unread message

Philip Rogers (Gerrit)

unread,
Sep 22, 2025, 7:16:58 PM (2 days ago) Sep 22
to Stefan Zager, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
Attention needed from Stefan Zager

Philip Rogers added 2 comments

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Philip Rogers . unresolved
Is this fixing the issue where we decode small placeholder images with large layout sizes? If so, can you add a test? I think you can just modify this one from one of your previous patches (the data url here is a 10x10 png):
```
TEST_F(WebFrameWidgetImplSimTest, SpeculativeImageDecodeBeforeLayout) {
// Check that a speculative decode can start as soon as an img element gets a
// src based on prior layout information, without waiting for a subsequent
// layout to happen.
base::test::ScopedFeatureList feature_list(
features::kSpeculativeImageDecodes);
SimRequest request("https://example.com/test.html", "text/html");
LoadURL("https://example.com/test.html");
request.Complete(R"HTML(
<!DOCTYPE html>
<html><body><img width=340 height=380/></body></html>
)HTML");
Compositor().BeginFrame();
HTMLImageElement* image =
To<HTMLImageElement>(GetDocument().QuerySelector(AtomicString("img")));
LayoutImage* layout_image = To<LayoutImage>(image->GetLayoutObject());
EXPECT_EQ(layout_image->CachedResourcePriority().visibility,
ResourcePriority::kVisible);
// Decode size should be based on layout size; note that this does not
// actually match the intrinsic size of the data URL below.
EXPECT_EQ(layout_image->CachedSpeculativeDecodeSize(), gfx::Size(340, 380));
  image->setAttribute(
html_names::kSrcAttr,
AtomicString("data:image/"
"png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+"
"9AAAAAXNSR0IArs4c6QAAABhJREFUKFNjbGj48J+BCMA4qhBfKFE/"
"eACQKR1hvTllHQAAAABJRU5ErkJggg=="));
// The fetch is initiated synchronously from a microtask after src is set. For
// a data URL the load will also finish synchronously, and the speculative
// decode should have been triggered, based on pre-computed visibility.
EXPECT_CALL(*MockMainFrameWidget(), RequestDecode(_, _, true)).Times(1);
GetDocument().GetAgent().PerformMicrotaskCheckpoint();
}
```
File third_party/blink/renderer/core/loader/frame_fetch_context.cc
Line 1013, Patchset 1 (Latest): if (!intrinsic_size.IsZero() &&
Philip Rogers . unresolved

should this be `if (intrinsic_size.IsZero() || ...)`?

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
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: I14889b8fe2d55e47a23bb5313590415b05a897be
Gerrit-Change-Number: 6974945
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Stefan Zager <sza...@chromium.org>
Gerrit-Comment-Date: Mon, 22 Sep 2025 23:16:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Stefan Zager (Gerrit)

unread,
Sep 23, 2025, 12:53:49 AM (yesterday) Sep 23
to Philip Rogers, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, 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/frame_fetch_context.cc
Line 1013, Patchset 1 (Latest): if (!intrinsic_size.IsZero() &&
Philip Rogers . unresolved

should this be `if (intrinsic_size.IsZero() || ...)`?

Stefan Zager

The idea here is that if an image doesn't have an available intrinsic size then we should go ahead and do the speculative decode since the content size is above the threshold and that's the best signal we have.

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
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: I14889b8fe2d55e47a23bb5313590415b05a897be
Gerrit-Change-Number: 6974945
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Philip Rogers <p...@chromium.org>
Gerrit-Comment-Date: Tue, 23 Sep 2025 04:53:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Philip Rogers <p...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Philip Rogers (Gerrit)

unread,
Sep 23, 2025, 12:42:20 PM (21 hours ago) Sep 23
to Stefan Zager, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
Attention needed from Stefan Zager

Philip Rogers added 2 comments

File third_party/blink/renderer/core/loader/frame_fetch_context.cc
Line 1009, Patchset 1 (Latest): // speculative decode. However, image instrinsic size is the strongest
Philip Rogers . unresolved

Please fix this WARNING reported by Spellchecker: "instrinsic" is a possible misspelling of "intrinsic".

To bypass Spellchecker, ...

"instrinsic" is a possible misspelling of "intrinsic".

To bypass Spellchecker, add a footer with DISABLE_SPELLCHECKER

Line 1013, Patchset 1 (Latest): if (!intrinsic_size.IsZero() &&
Philip Rogers . unresolved

should this be `if (intrinsic_size.IsZero() || ...)`?

Stefan Zager

The idea here is that if an image doesn't have an available intrinsic size then we should go ahead and do the speculative decode since the content size is above the threshold and that's the best signal we have.

Philip Rogers

The intrinsic size is the size in the image file itself. Don't we need that to do any decoding?

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
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: I14889b8fe2d55e47a23bb5313590415b05a897be
Gerrit-Change-Number: 6974945
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Stefan Zager <sza...@chromium.org>
Gerrit-Comment-Date: Tue, 23 Sep 2025 16:42:09 +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,
Sep 23, 2025, 12:51:54 PM (21 hours ago) Sep 23
to Philip Rogers, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, 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/frame_fetch_context.cc
Line 1013, Patchset 1 (Latest): if (!intrinsic_size.IsZero() &&
Philip Rogers . unresolved

should this be `if (intrinsic_size.IsZero() || ...)`?

Stefan Zager

The idea here is that if an image doesn't have an available intrinsic size then we should go ahead and do the speculative decode since the content size is above the threshold and that's the best signal we have.

Philip Rogers

The intrinsic size is the size in the image file itself. Don't we need that to do any decoding?

Stefan Zager

I do not know the answer to that, but looking at some of the image generators, it's not clear to me that the intrinsic size is always available at load time.

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
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: I14889b8fe2d55e47a23bb5313590415b05a897be
Gerrit-Change-Number: 6974945
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Philip Rogers <p...@chromium.org>
Gerrit-Comment-Date: Tue, 23 Sep 2025 16:51:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Philip Rogers <p...@chromium.org>
Comment-In-Reply-To: Stefan Zager <sza...@chromium.org>
satisfied_requirement
unsatisfied_requirement
open
diffy

Philip Rogers (Gerrit)

unread,
Sep 23, 2025, 1:18:57 PM (21 hours ago) Sep 23
to Stefan Zager, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
Attention needed from Stefan Zager

Philip Rogers added 2 comments

File third_party/blink/renderer/core/loader/frame_fetch_context.cc
Line 1008, Patchset 1 (Latest): // Prior to image load, we use content size to qualify as a candidate for
Philip Rogers . unresolved

WDYT of moving this logic next to the layout size logic in ImageResource::IsAboveSpeculativeDecodeSizeThreshold?

Line 1013, Patchset 1 (Latest): if (!intrinsic_size.IsZero() &&
Philip Rogers . unresolved

should this be `if (intrinsic_size.IsZero() || ...)`?

Stefan Zager

The idea here is that if an image doesn't have an available intrinsic size then we should go ahead and do the speculative decode since the content size is above the threshold and that's the best signal we have.

Philip Rogers

The intrinsic size is the size in the image file itself. Don't we need that to do any decoding?

Stefan Zager

I do not know the answer to that, but looking at some of the image generators, it's not clear to me that the intrinsic size is always available at load time.

Philip Rogers

The intrinsic size is in the first few bytes of an image file. I am pretty sure that information is a hard requirement for decoding. I think we can actually CHECK here that the size isn't zero, because none of the image formats used on the web allow for 0x0 images.

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
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: I14889b8fe2d55e47a23bb5313590415b05a897be
Gerrit-Change-Number: 6974945
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Stefan Zager <sza...@chromium.org>
Gerrit-Comment-Date: Tue, 23 Sep 2025 17:18:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Stefan Zager (Gerrit)

unread,
Sep 23, 2025, 6:57:45 PM (15 hours ago) Sep 23
to Philip Rogers, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-...@chromium.org, gavinp...@chromium.org, loading...@chromium.org
Attention needed from Philip Rogers

Stefan Zager added 4 comments

Patchset-level comments
File-level comment, Patchset 1:
Philip Rogers . resolved
Stefan Zager

I modified an existing test to cover this case.

File third_party/blink/renderer/core/loader/frame_fetch_context.cc
Line 1008, Patchset 1: // Prior to image load, we use content size to qualify as a candidate for
Philip Rogers . resolved

WDYT of moving this logic next to the layout size logic in ImageResource::IsAboveSpeculativeDecodeSizeThreshold?

Stefan Zager

Done

Line 1009, Patchset 1: // speculative decode. However, image instrinsic size is the strongest
Philip Rogers . resolved

Please fix this WARNING reported by Spellchecker: "instrinsic" is a possible misspelling of "intrinsic".

To bypass Spellchecker, ...

"instrinsic" is a possible misspelling of "intrinsic".

To bypass Spellchecker, add a footer with DISABLE_SPELLCHECKER

Stefan Zager

Done

Line 1013, Patchset 1: if (!intrinsic_size.IsZero() &&
Philip Rogers . resolved

should this be `if (intrinsic_size.IsZero() || ...)`?

Stefan Zager

The idea here is that if an image doesn't have an available intrinsic size then we should go ahead and do the speculative decode since the content size is above the threshold and that's the best signal we have.

Philip Rogers

The intrinsic size is the size in the image file itself. Don't we need that to do any decoding?

Stefan Zager

I do not know the answer to that, but looking at some of the image generators, it's not clear to me that the intrinsic size is always available at load time.

Philip Rogers

The intrinsic size is in the first few bytes of an image file. I am pretty sure that information is a hard requirement for decoding. I think we can actually CHECK here that the size isn't zero, because none of the image formats used on the web allow for 0x0 images.

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
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: I14889b8fe2d55e47a23bb5313590415b05a897be
Gerrit-Change-Number: 6974945
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Zager <sza...@chromium.org>
Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Philip Rogers <p...@chromium.org>
Gerrit-Comment-Date: Tue, 23 Sep 2025 22:57:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Philip Rogers (Gerrit)

unread,
Sep 23, 2025, 7:00:48 PM (15 hours ago) Sep 23
to Stefan Zager, Daniel Cheng, AyeAye, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, blink-revi...@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

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Philip Rogers . resolved

LGTM

Open in Gerrit

Related details

Attention is currently required from:
  • Stefan Zager
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    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: I14889b8fe2d55e47a23bb5313590415b05a897be
    Gerrit-Change-Number: 6974945
    Gerrit-PatchSet: 2
    Gerrit-Owner: Stefan Zager <sza...@chromium.org>
    Gerrit-Reviewer: Philip Rogers <p...@chromium.org>
    Gerrit-Reviewer: Stefan Zager <sza...@chromium.org>
    Gerrit-CC: Daniel Cheng <dch...@chromium.org>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Stefan Zager <sza...@chromium.org>
    Gerrit-Comment-Date: Tue, 23 Sep 2025 23:00:37 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages