<?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>95465</bug_id>
          
          <creation_ts>2012-08-30 08:48:10 -0700</creation_ts>
          <short_desc>[Mac] Registering web views for notifications is unbalanced</short_desc>
          <delta_ts>2012-08-31 10:53:34 -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>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.7</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="Jon Lee">jonlee</reporter>
          <assigned_to name="Jon Lee">jonlee</assigned_to>
          <cc>ap</cc>
    
    <cc>jberlin</cc>
    
    <cc>sam</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>708670</commentid>
    <comment_count>0</comment_count>
    <who name="Jon Lee">jonlee</who>
    <bug_when>2012-08-30 08:48:10 -0700</bug_when>
    <thetext>Setting the notification provider for a WK1 WebView registers that web view to the provider. When the WebView is closed, WebCore is essentially responsible for unregistering the web view. This leads to an imbalance on Lion since notifications are not supported, and the NotificationController responsible for making the unregistration call doesn&apos;t exist.

Instead, the unregisterWebView method should be called when the web view is closed, keeping both calls within WebKit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>708671</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2012-08-30 08:48:20 -0700</bug_when>
    <thetext>&lt;rdar://problem/12206765&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>708737</commentid>
    <comment_count>2</comment_count>
      <attachid>161499</attachid>
    <who name="Jon Lee">jonlee</who>
    <bug_when>2012-08-30 09:48:59 -0700</bug_when>
    <thetext>Created attachment 161499
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>708771</commentid>
    <comment_count>3</comment_count>
      <attachid>161499</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2012-08-30 10:09:39 -0700</bug_when>
    <thetext>Comment on attachment 161499
Patch

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

&gt; Source/WebKit/mac/WebView/WebView.mm:1143
&gt; +    [[self _notificationProvider] unregisterWebView:self];

What about the _closeWithFastTeardown case? Are we OK not unregistering in that case? Could something bad happen during the rest of the application termination process?

&gt; Source/WebKit/mac/WebView/WebView.mm:6526
&gt;  - (void)_setNotificationProvider:(id&lt;WebNotificationProvider&gt;)notificationProvider
&gt;  {
&gt; -    if (_private) {
&gt; +    if (_private &amp;&amp; !_private-&gt;_notificationProvider) {
&gt;          _private-&gt;_notificationProvider = notificationProvider;
&gt;          [_private-&gt;_notificationProvider registerWebView:self];
&gt;      }
&gt;  }

It seems a little non-obvious that this method does nothing once a notification provider is set. Are the callers able to tolerate this behavior? The alternative would be to teach this function to unregister the old provider when setting a new one.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>708834</commentid>
    <comment_count>4</comment_count>
    <who name="Jon Lee">jonlee</who>
    <bug_when>2012-08-30 10:56:41 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; (From update of attachment 161499 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=161499&amp;action=review
&gt; 
&gt; &gt; Source/WebKit/mac/WebView/WebView.mm:1143
&gt; &gt; +    [[self _notificationProvider] unregisterWebView:self];
&gt; 
&gt; What about the _closeWithFastTeardown case? Are we OK not unregistering in that case? Could something bad happen during the rest of the application termination process?

I considered that, but did not see any harm with not unregistering in this situation. The registered web view is called either from WebCore or when there is some user interaction with the platform notification, but in the latter case that is code in the provider.

&gt; 
&gt; &gt; Source/WebKit/mac/WebView/WebView.mm:6526
&gt; &gt;  - (void)_setNotificationProvider:(id&lt;WebNotificationProvider&gt;)notificationProvider
&gt; &gt;  {
&gt; &gt; -    if (_private) {
&gt; &gt; +    if (_private &amp;&amp; !_private-&gt;_notificationProvider) {
&gt; &gt;          _private-&gt;_notificationProvider = notificationProvider;
&gt; &gt;          [_private-&gt;_notificationProvider registerWebView:self];
&gt; &gt;      }
&gt; &gt;  }
&gt; 
&gt; It seems a little non-obvious that this method does nothing once a notification provider is set. Are the callers able to tolerate this behavior? The alternative would be to teach this function to unregister the old provider when setting a new one.

The provider is set once, typically during initialization of the web view. There is no reason I can think of that one would want to switch providers in the middle of the web view&apos;s lifetime. The case is similar with other kinds of providers like geolocation.

Because of the use case, I opted to just go with initialize-once rather than unregister-the-old-provider, since that is not the intended use for this method. Maybe renaming this to _initializeNotificationProvider would be more descriptive.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>708835</commentid>
    <comment_count>5</comment_count>
    <who name="Jon Lee">jonlee</who>
    <bug_when>2012-08-30 10:59:17 -0700</bug_when>
    <thetext>Committed r127161: &lt;http://trac.webkit.org/changeset/127161&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>709784</commentid>
    <comment_count>6</comment_count>
      <attachid>161499</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2012-08-31 10:39:09 -0700</bug_when>
    <thetext>Comment on attachment 161499
Patch

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

&gt;&gt;&gt; Source/WebKit/mac/WebView/WebView.mm:6526
&gt;&gt;&gt;  }
&gt;&gt; 
&gt;&gt; It seems a little non-obvious that this method does nothing once a notification provider is set. Are the callers able to tolerate this behavior? The alternative would be to teach this function to unregister the old provider when setting a new one.
&gt; 
&gt; The provider is set once, typically during initialization of the web view. There is no reason I can think of that one would want to switch providers in the middle of the web view&apos;s lifetime. The case is similar with other kinds of providers like geolocation.
&gt; 
&gt; Because of the use case, I opted to just go with initialize-once rather than unregister-the-old-provider, since that is not the intended use for this method. Maybe renaming this to _initializeNotificationProvider would be more descriptive.

The name change is one possible way to increase clarity. Another would be to add an ASSERT_NOT_REACHED along with early return instead of nesting the function inside an if. The _private == nil case seems expected and harmless while the !_private-&gt;_notificationProvider seems like it always reflects a programming error. Might also want to assert that the provider is non-nil or something.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>709801</commentid>
    <comment_count>7</comment_count>
      <attachid>161499</attachid>
    <who name="Jon Lee">jonlee</who>
    <bug_when>2012-08-31 10:53:34 -0700</bug_when>
    <thetext>Comment on attachment 161499
Patch

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

&gt;&gt;&gt;&gt; Source/WebKit/mac/WebView/WebView.mm:6526
&gt;&gt;&gt;&gt;  }
&gt;&gt;&gt; 
&gt;&gt;&gt; It seems a little non-obvious that this method does nothing once a notification provider is set. Are the callers able to tolerate this behavior? The alternative would be to teach this function to unregister the old provider when setting a new one.
&gt;&gt; 
&gt;&gt; The provider is set once, typically during initialization of the web view. There is no reason I can think of that one would want to switch providers in the middle of the web view&apos;s lifetime. The case is similar with other kinds of providers like geolocation.
&gt;&gt; 
&gt;&gt; Because of the use case, I opted to just go with initialize-once rather than unregister-the-old-provider, since that is not the intended use for this method. Maybe renaming this to _initializeNotificationProvider would be more descriptive.
&gt; 
&gt; The name change is one possible way to increase clarity. Another would be to add an ASSERT_NOT_REACHED along with early return instead of nesting the function inside an if. The _private == nil case seems expected and harmless while the !_private-&gt;_notificationProvider seems like it always reflects a programming error. Might also want to assert that the provider is non-nil or something.

Filed bug 95589 to track this work.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>161499</attachid>
            <date>2012-08-30 09:48:59 -0700</date>
            <delta_ts>2012-08-31 10:53:34 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-95465-20120830094848.patch</filename>
            <type>text/plain</type>
            <size>4197</size>
            <attacher name="Jon Lee">jonlee</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTI3MTUyCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L21h
Yy9DaGFuZ2VMb2cgYi9Tb3VyY2UvV2ViS2l0L21hYy9DaGFuZ2VMb2cKaW5kZXggMTFmMDM1OGRi
NDk3NDUzYWUyMWNiMzM3M2FkYzJmMzBkMTIzZDkxZC4uOWNhMDQyNjZkMmMwNzFjMDI3YTYyNTE0
NjY1ZjBlNDQ5MmNjMDFjZiAxMDA2NDQKLS0tIGEvU291cmNlL1dlYktpdC9tYWMvQ2hhbmdlTG9n
CisrKyBiL1NvdXJjZS9XZWJLaXQvbWFjL0NoYW5nZUxvZwpAQCAtMSwzICsxLDI5IEBACisyMDEy
LTA4LTMwICBKb24gTGVlICA8am9ubGVlQGFwcGxlLmNvbT4KKworICAgICAgICBbTWFjXSBSZWdp
c3RlcmluZyB3ZWIgdmlld3MgZm9yIG5vdGlmaWNhdGlvbnMgaXMgdW5iYWxhbmNlZAorICAgICAg
ICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9OTU0NjUKKyAgICAgICAg
PHJkYXI6Ly9wcm9ibGVtLzEyMjA2NzY1PgorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAo
T09QUyEpLgorCisgICAgICAgIFNldHRpbmcgdGhlIG5vdGlmaWNhdGlvbiBwcm92aWRlciBmb3Ig
YSBXSzEgV2ViVmlldyByZWdpc3RlcnMgdGhhdCB3ZWIgdmlldyB0byB0aGUKKyAgICAgICAgcHJv
dmlkZXIuIFdoZW4gdGhlIFdlYlZpZXcgaXMgY2xvc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vdWxkIGJlIHdvcnRoIGFkZGluZyB0byB0aGUgQVBJLgogQGludGVyZmFjZSBXZWJWaWV3
IChXZWJWaWV3Tm90aWZpY2F0aW9uKQogLSAodm9pZClfc2V0Tm90aWZpY2F0aW9uUHJvdmlkZXI6
KGlkPFdlYk5vdGlmaWNhdGlvblByb3ZpZGVyPilub3RpZmljYXRpb25Qcm92aWRlcjsKIC0gKGlk
PFdlYk5vdGlmaWNhdGlvblByb3ZpZGVyPilfbm90aWZpY2F0aW9uUHJvdmlkZXI7Ci0tICh2b2lk
KV9ub3RpZmljYXRpb25Db250cm9sbGVyRGVzdHJveWVkOwogCiAtICh2b2lkKV9ub3RpZmljYXRp
b25EaWRTaG93Oih1aW50NjRfdClub3RpZmljYXRpb25JRDsKIC0gKHZvaWQpX25vdGlmaWNhdGlv
bkRpZENsaWNrOih1aW50NjRfdClub3RpZmljYXRpb25JRDsK
</data>
<flag name="review"
          id="172331"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>