Bug 211620

Summary: Incorrect image srcset candidate chosen for <img> cloned from <template>
Product: WebKit Reporter: Javan Makhmali <javan>
Component: ImagesAssignee: Ryosuke Niwa <rniwa>
Severity: Normal CC: ahmad.saleem792, ap, bfulgham, karlcow, mmaxfield, rik, rniwa, sabouhallawa, simon.fraser, vitor.roriz, webkit-bug-importer, zalan
Priority: P2 Keywords: BrowserCompat, HasReduction, InRadar
Version: Safari 13   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=244815
Description Flags
Minimal test case
Screenshot of test case
Browser comparison none

Description Javan Makhmali 2020-05-08 03:08:16 PDT
Created attachment 398848 [details]
Minimal test case

To reproduce: Open the attached template-img-srcset.html file in Safari on a 2x DPR or higher display.

Expected: Both images load the same URL.

Actual: The first image loads the correct URL. The second image (cloned from a <template>) incorrectly loads the first URL from its srcset.
Comment 1 Javan Makhmali 2020-05-08 03:09:11 PDT
Created attachment 398849 [details]
Screenshot of test case
Comment 2 Javan Makhmali 2020-05-08 03:58:25 PDT
Created attachment 398853 [details]
Browser comparison

Does not occur in Firefox or Chrome (top). Does occur in Safari and Safari Technology Preview (bottom).
Comment 3 Radar WebKit Bug Importer 2020-05-08 15:45:11 PDT
Comment 4 Ahmad Saleem 2022-08-29 08:05:20 PDT
I am able to reproduce this bug in Safari Technology Preview 152 and Safari 15.6.1 on macOS 12.5.1 using attached test case and it shows "2x" and "1x" while all other browsers show "2x" and "2x".

Weirdly. on iOS 15.6.1 on iPhone 13 Pro Max, it shows "3x" and "1x". Just wanted to share latest testing results. Thanks!
Comment 5 Ryosuke Niwa 2022-08-31 11:27:12 PDT
Pull request: https://github.com/WebKit/WebKit/pull/3864
Comment 6 Anthony Ricaud 2022-09-05 11:00:32 PDT
Based on a Twitter conversation, I've opened bug 244815. This seems very similar.
Comment 7 Ryosuke Niwa 2022-09-10 14:45:44 PDT
*** Bug 244815 has been marked as a duplicate of this bug. ***
Comment 8 Ryosuke Niwa 2022-09-10 15:00:44 PDT
Pull request: https://github.com/WebKit/WebKit/pull/4228
Comment 9 EWS 2022-09-10 21:17:32 PDT
Committed 254361@main (ebdff21ed516): <https://commits.webkit.org/254361@main>

Reviewed commits have been landed. Closing PR #4228 and removing active labels.