<?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>256335</bug_id>
          
          <creation_ts>2023-05-04 14:49:33 -0700</creation_ts>
          <short_desc>[GLib] Audit and fix incorrect use of (closure) in WebKit</short_desc>
          <delta_ts>2023-05-05 06:37:50 -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>WebKitGTK</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Michael Catanzaro">mcatanzaro</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1953012</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2023-05-04 14:49:33 -0700</bug_when>
    <thetext>Following Emmanuele&apos;s guidance in https://www.bassi.io/articles/2023/02/20/bindable-api-2023/ I have audited our use of (closure) annotations in WebKit and found they are all incorrect. Unary (closure) is only allowed on function typedefs; in function declarations an argument is always required, e.g. (closure user_data). But (closure user_data) is actually default, so most of our annotations can actually be removed.

It looks like this was not causing many problems in practice. For example, let&apos;s look at the callback parameter to jsc_class_add_constructor generated *before* this patch:

          &lt;parameter name=&quot;callback&quot;
                     transfer-ownership=&quot;none&quot;
                     scope=&quot;notified&quot;
                     closure=&quot;2&quot;
                     destroy=&quot;3&quot;&gt;
            &lt;doc xml:space=&quot;preserve&quot;
                 filename=&quot;Source/JavaScriptCore/API/glib/JSCClass.cpp&quot;
                 line=&quot;569&quot;&gt;a #GCallback to be called to create an instance of @jsc_class&lt;/doc&gt;
            &lt;type name=&quot;GObject.Callback&quot; c:type=&quot;GCallback&quot;/&gt;
          &lt;/parameter&gt;

This already looks fine: it knows the closure parameter comes right after callback, which is the correct order. So even though Emmanuele says this use of unary closure was incorrect, it wasn&apos;t causing problems in practice.

Looking through the generated JavaScriptCore-6.0.gir, this results in gir changes for only jsc_value_new_array_buffer and jsc_value_new_typed_array_with_buffer, where the closure parameter was previously not detected, which is now fixed. I don&apos;t think this resulted in any changes to WebKit-6.0.gir.

I&apos;ve also fixed WPE&apos;s webkit_web_view_add_frame_displayed_callback() where the callback parameter defaulted to (scope call), causing it to be valid only for the duration of the function call.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1953013</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2023-05-04 14:51:27 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/13460</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1953141</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2023-05-05 06:32:13 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #0)
&gt; So even though Emmanuele says this use
&gt; of unary closure was incorrect, it wasn&apos;t causing problems in practice.

It will soon, though: Emmanuele is going to make the introspection scanner complain when it sees this, and that will probably cause our builds to fail.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1953145</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-05-05 06:37:47 -0700</bug_when>
    <thetext>Committed 263714@main (56d72f891945): &lt;https://commits.webkit.org/263714@main&gt;

Reviewed commits have been landed. Closing PR #13460 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>