<?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>200528</bug_id>
          
          <creation_ts>2019-08-07 19:31:32 -0700</creation_ts>
          <short_desc>Set WKWebView opaque based on drawsBackground in PageConfiguration</short_desc>
          <delta_ts>2019-08-15 17:43:23 -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>WebKit Misc.</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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="Timothy Hatcher">timothy</reporter>
          <assigned_to name="Timothy Hatcher">timothy</assigned_to>
          <cc>bdakin</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>thorton</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1559417</commentid>
    <comment_count>0</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2019-08-07 19:31:32 -0700</bug_when>
    <thetext>Setting opaque early puts the transparent backgroundColor in the WebPageCreationParameters and avoids a page message later, and some extra transparency/layout thrash.

&lt;rdar://problem/53859380&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1559422</commentid>
    <comment_count>1</comment_count>
      <attachid>375781</attachid>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2019-08-07 19:40:22 -0700</bug_when>
    <thetext>Created attachment 375781
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1559615</commentid>
    <comment_count>2</comment_count>
      <attachid>375781</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-08-08 12:04:47 -0700</bug_when>
    <thetext>Comment on attachment 375781
Patch

Clearing flags on attachment: 375781

Committed r248436: &lt;https://trac.webkit.org/changeset/248436&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1559616</commentid>
    <comment_count>3</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-08-08 12:04:49 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1559629</commentid>
    <comment_count>4</comment_count>
      <attachid>375781</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2019-08-08 12:51:24 -0700</bug_when>
    <thetext>Comment on attachment 375781
Patch

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

&gt; Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:715
&gt; +    if (!self.opaque || !pageConfiguration-&gt;drawsBackground())
&gt; +        self.opaque = NO;

Is checking the existing value of self.opaque an important optimization?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1559631</commentid>
    <comment_count>5</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2019-08-08 12:55:35 -0700</bug_when>
    <thetext>(In reply to Darin Adler from comment #4)
&gt; Comment on attachment 375781 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=375781&amp;action=review
&gt; 
&gt; &gt; Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:715
&gt; &gt; +    if (!self.opaque || !pageConfiguration-&gt;drawsBackground())
&gt; &gt; +        self.opaque = NO;
&gt; 
&gt; Is checking the existing value of self.opaque an important optimization?

This ensures a subclass overriding opaque will get NO propagated down to our setter which does internal work that might get skipped otherwise. (It also preserves the old logic.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1559634</commentid>
    <comment_count>6</comment_count>
      <attachid>375781</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2019-08-08 12:59:29 -0700</bug_when>
    <thetext>Comment on attachment 375781
Patch

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

&gt;&gt;&gt; Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:715
&gt;&gt;&gt; +        self.opaque = NO;
&gt;&gt; 
&gt;&gt; Is checking the existing value of self.opaque an important optimization?
&gt; 
&gt; This ensures a subclass overriding opaque will get NO propagated down to our setter which does internal work that might get skipped otherwise. (It also preserves the old logic.)

I don’t understand. This code skips calling the setter in the case where the getter is overridden to return NO. So how does that ensure that NO will get propagated to our setter? Sounds backwards.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1559640</commentid>
    <comment_count>7</comment_count>
      <attachid>375781</attachid>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2019-08-08 13:10:53 -0700</bug_when>
    <thetext>Comment on attachment 375781
Patch

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

&gt;&gt;&gt;&gt; Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:715
&gt;&gt;&gt;&gt; +        self.opaque = NO;
&gt;&gt;&gt; 
&gt;&gt;&gt; Is checking the existing value of self.opaque an important optimization?
&gt;&gt; 
&gt;&gt; This ensures a subclass overriding opaque will get NO propagated down to our setter which does internal work that might get skipped otherwise. (It also preserves the old logic.)
&gt; 
&gt; I don’t understand. This code skips calling the setter in the case where the getter is overridden to return NO. So how does that ensure that NO will get propagated to our setter? Sounds backwards.

The check is !self.opaque || !pageConfiguration-&gt;drawsBackground().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1559696</commentid>
    <comment_count>8</comment_count>
      <attachid>375781</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2019-08-08 16:01:51 -0700</bug_when>
    <thetext>Comment on attachment 375781
Patch

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

&gt;&gt;&gt;&gt;&gt; Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:715
&gt;&gt;&gt;&gt;&gt; +        self.opaque = NO;
&gt;&gt;&gt;&gt; 
&gt;&gt;&gt;&gt; Is checking the existing value of self.opaque an important optimization?
&gt;&gt;&gt; 
&gt;&gt;&gt; This ensures a subclass overriding opaque will get NO propagated down to our setter which does internal work that might get skipped otherwise. (It also preserves the old logic.)
&gt;&gt; 
&gt;&gt; I don’t understand. This code skips calling the setter in the case where the getter is overridden to return NO. So how does that ensure that NO will get propagated to our setter? Sounds backwards.
&gt; 
&gt; The check is !self.opaque || !pageConfiguration-&gt;drawsBackground().

Got it! Thanks. I was the one who had it backwards. Now makes total sense to me. I think we could follow up and make this better in three ways:

1a) Adding a comment could be helpful since the setter here is &quot;impure&quot; and someone might not understand that later. Maybe making the same mistake I made.

    // There is valuable code in the setter for &quot;opaque&quot; that we want to call explicitly if opaque is overridden to return NO.

1b) Move the valuable code in the setter for opaque into a different method, and call that method unconditionally instead of relying on the side effect of the setter.

2) Add a test case that overrides opaque to return NO to TestWebKitAPI to catch when this is broken by a future well-meaning programmers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1561861</commentid>
    <comment_count>9</comment_count>
    <who name="Timothy Hatcher">timothy</who>
    <bug_when>2019-08-15 17:43:23 -0700</bug_when>
    <thetext>(In reply to Darin Adler from comment #8)
&gt; Comment on attachment 375781 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=375781&amp;action=review
&gt; 
&gt; &gt;&gt;&gt;&gt;&gt; Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:715
&gt; &gt;&gt;&gt;&gt;&gt; +        self.opaque = NO;
&gt; &gt;&gt;&gt;&gt; 
&gt; &gt;&gt;&gt;&gt; Is checking the existing value of self.opaque an important optimization?
&gt; &gt;&gt;&gt; 
&gt; &gt;&gt;&gt; This ensures a subclass overriding opaque will get NO propagated down to our setter which does internal work that might get skipped otherwise. (It also preserves the old logic.)
&gt; &gt;&gt; 
&gt; &gt;&gt; I don’t understand. This code skips calling the setter in the case where the getter is overridden to return NO. So how does that ensure that NO will get propagated to our setter? Sounds backwards.
&gt; &gt; 
&gt; &gt; The check is !self.opaque || !pageConfiguration-&gt;drawsBackground().
&gt; 
&gt; Got it! Thanks. I was the one who had it backwards. Now makes total sense to
&gt; me. I think we could follow up and make this better in three ways:
&gt; 
&gt; 1a) Adding a comment could be helpful since the setter here is &quot;impure&quot; and
&gt; someone might not understand that later. Maybe making the same mistake I
&gt; made.
&gt; 
&gt;     // There is valuable code in the setter for &quot;opaque&quot; that we want to
&gt; call explicitly if opaque is overridden to return NO.
&gt; 
&gt; 1b) Move the valuable code in the setter for opaque into a different method,
&gt; and call that method unconditionally instead of relying on the side effect
&gt; of the setter.
&gt; 
&gt; 2) Add a test case that overrides opaque to return NO to TestWebKitAPI to
&gt; catch when this is broken by a future well-meaning programmers.

Addressed in bug 200802.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>375781</attachid>
            <date>2019-08-07 19:40:22 -0700</date>
            <delta_ts>2019-08-08 12:04:47 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-200528-20190807194021.patch</filename>
            <type>text/plain</type>
            <size>2432</size>
            <attacher name="Timothy Hatcher">timothy</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjQ4MzI2CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCmluZGV4IGRmZTIwOTA5OTI3NGQ1NjI4
MTEzOTBlN2Y5MzBiNTdlMGE3ZjNlODYuLjBlY2JkNjhiN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