<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>240100</bug_id>
          
          <creation_ts>2022-05-04 17:24:57 -0700</creation_ts>
          <short_desc>[GPU Process] [iOS] REGRESSION(r293570): Snapshot rendering is not scaled with the device scale factor</short_desc>
          <delta_ts>2022-05-05 01:20:29 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=239527</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=225081</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Said Abou-Hallawa">sabouhallawa</reporter>
          <assigned_to name="Said Abou-Hallawa">sabouhallawa</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1866679</commentid>
    <comment_count>0</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2022-05-04 17:24:57 -0700</bug_when>
    <thetext>In r293570, the GPU Process was enabled for snapshot images. Before r293570, a local ImageBuffer was created in snapshotFrameRectWithClip(). Then in WebFrame::createSelectionSnapshot(), the pixels of the ImageBuffer were copied to a WebImage, which was backed by a ShareableBitmap.

r293570 made snapshotFrameRectWithClip() create a remote ImageBuffer which is moved to a WebImage in WebFrame::createSelectionSnapshot(). This remote ImageBuffer has to have ImageBufferShareableBitmapBackend so it can provide ShareableBitmap without allocating any extra memory.

The problem is in initializing the GraphicsContext of ImageBufferShareableBitmapBackend. The scaling factor is not set to the CTM of the ImageBufferShareableBitmapBackend context. See the comment in ImageBufferShareableBitmapBackend constructor and notice that this function does not call applyBaseTransformToContext().

A simple approach to fix this bug is to make snapshotFrameRectWithClip() handle the scaling outside the ImageBuffer creation. This is similar to what we do in GraphicsContext::createAlignedImageBuffer() where we scale the size and create the ImageBuffer with scaleFactor = 1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1866680</commentid>
    <comment_count>1</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2022-05-04 17:25:24 -0700</bug_when>
    <thetext>rdar://92635752</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1866681</commentid>
    <comment_count>2</comment_count>
      <attachid>458839</attachid>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2022-05-04 17:30:05 -0700</bug_when>
    <thetext>Created attachment 458839
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1866703</commentid>
    <comment_count>3</comment_count>
      <attachid>458839</attachid>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2022-05-04 19:14:59 -0700</bug_when>
    <thetext>Comment on attachment 458839
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=458839&amp;action=review

&gt; Source/WebCore/page/FrameSnapshotting.cpp:124
&gt; -    auto buffer = ImageBuffer::create(imageRect.size(), purpose, scaleFactor, options.colorSpace, options.pixelFormat, { }, { hostWindow });
&gt; +    auto buffer = ImageBuffer::create(scaledImageRect.size(), purpose, 1, options.colorSpace, options.pixelFormat, { }, { hostWindow });

It&apos;s odd that ImageBuffer::create() takes a scale factor argument, but apparently that doesn&apos;t behave the way we want?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1866743</commentid>
    <comment_count>4</comment_count>
      <attachid>458839</attachid>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2022-05-04 21:53:46 -0700</bug_when>
    <thetext>Comment on attachment 458839
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=458839&amp;action=review

&gt;&gt; Source/WebCore/page/FrameSnapshotting.cpp:124
&gt;&gt; +    auto buffer = ImageBuffer::create(scaledImageRect.size(), purpose, 1, options.colorSpace, options.pixelFormat, { }, { hostWindow });
&gt; 
&gt; It&apos;s odd that ImageBuffer::create() takes a scale factor argument, but apparently that doesn&apos;t behave the way we want?

I think it is okay that we want the scaling of the ImageBuffer to happen at the creation time. And it is working for all the other backends. But there is a problem with ImageBufferShareableBitmapBackend which I can&apos;t figure it out so far. 

This patch is correct and it fixes the snapshot bug. But we do have a bug with creating scaled unaccelerated remote ImageBuffer which we never needed before. All the canvas ImageBuffers are not scaled and all the layer ImageBuffers are accelerated. So I will file another bug for this issue which can be fixed later.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1866776</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-05-05 01:20:26 -0700</bug_when>
    <thetext>Committed r293825 (250298@main): &lt;https://commits.webkit.org/250298@main&gt;

All reviewed patches have been landed. Closing bug and clearing flags on attachment 458839.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>458839</attachid>
            <date>2022-05-04 17:30:05 -0700</date>
            <delta_ts>2022-05-05 01:20:28 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-240100-20220504173004.patch</filename>
            <type>text/plain</type>
            <size>2831</size>
            <attacher name="Said Abou-Hallawa">sabouhallawa</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjkzNzIxCmRpZmYgL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