<?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>227360</bug_id>
          
          <creation_ts>2021-06-24 10:00:54 -0700</creation_ts>
          <short_desc>WebKitGTK fails to handle some keypresses when built with the GTK Quartz backend on macOS</short_desc>
          <delta_ts>2021-09-02 20:37:21 -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 Local Build</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>macOS 10.14</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></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>discuss</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>berto</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>clopez</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>gustavo</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1772326</commentid>
    <comment_count>0</comment_count>
    <who name="">discuss</who>
    <bug_when>2021-06-24 10:00:54 -0700</bug_when>
    <thetext># What&apos;s affected

Browsers built with WebkitGTK and the GTK Quartz backend. I&apos;ve noticed this behavior while trying out the Nyxt browser[1] on macOS.

# How to reproduce

1. Build and run the MiniBrowser
2. Open any website with a text input field
3. Type &quot;abc&quot; into the input field

# What&apos;s expected to happen

&quot;abc&quot; is displayed in the input field.

# What actually happens

Nothing.

# The cause

The problem is caused by the input method handling code in WebKitGTK. When using the Quartz backend, WebKit throws out some text inputs that are passed through GTK&apos;s input method interface.

My understanding is that GTK based input method systems may choose to consume keypress events in order to compose non-alphabetic text[2][3][4]. The consumed keypresses are processed by the input method systems as part of the &quot;preediting&quot; phase, and the final composed text is passed back to WebKit through a &quot;commit&quot; signal[5].

There is a complication here however, because different input method implementations consume keypresses differently. Based on what I&apos;ve observed, the iBus input method on Linux doesn&apos;t consume simple alphabetical inputs and leaves WebKit to handle keypress events directly. On the other hand, GTK&apos;s Quartz backend on macOS consumes simple alphabetical inputs[6] and immediately fires the &quot;commit&quot; signal, accompanied by a &quot;preedit-changed&quot; signal[7][8]. This in turn causes WebKit to ignore the keypress event[9] *and* the &quot;commit&quot; signal fired by GTK[10]. And hence the issues.

[1]: https://nyxt.atlas.engineer
[2]: https://github.com/WebKit/WebKit/blob/a705747a1538dbb82ebc30f11d5413e67a0fa758/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp#L1101-L1102
[3]: https://github.com/WebKit/WebKit/blob/0c141f987eda765a8cc36509147542c160c52d0d/Source/WebKit/UIProcess/API/glib/InputMethodFilter.cpp#L99
[4]: https://github.com/WebKit/WebKit/blob/8afe31a018b11741abdf9b4d5bb973d7c1d9ff05/Source/WebKit/UIProcess/API/gtk/WebKitInputMethodContextImplGtk.cpp#L178
[5]: https://developer.gnome.org/gtk3/stable/GtkIMContext.html
[6]: https://github.com/GNOME/gtk/blob/77f32a69c0a35ffd3a1a542a6057c1c6d13c793d/gdk/quartz/GdkQuartzView.c#L239-L240
[7]: https://github.com/GNOME/gtk/blob/77f32a69c0a35ffd3a1a542a6057c1c6d13c793d/modules/input/imquartz.c#L163-L164
[8]: https://github.com/GNOME/gtk/blob/77f32a69c0a35ffd3a1a542a6057c1c6d13c793d/modules/input/imquartz.c#L206
[9]: https://github.com/WebKit/WebKit/blob/8afe31a018b11741abdf9b4d5bb973d7c1d9ff05/Source/WebKit/UIProcess/API/glib/InputMethodFilter.cpp#L116-L118
[10]: https://github.com/WebKit/WebKit/blob/8afe31a018b11741abdf9b4d5bb973d7c1d9ff05/Source/WebKit/UIProcess/API/glib/InputMethodFilter.cpp#L326-L327</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1772333</commentid>
    <comment_count>1</comment_count>
      <attachid>432180</attachid>
    <who name="">discuss</who>
    <bug_when>2021-06-24 10:09:55 -0700</bug_when>
    <thetext>Created attachment 432180
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1772336</commentid>
    <comment_count>2</comment_count>
    <who name="EWS Watchlist">ews-watchlist</who>
    <bug_when>2021-06-24 10:11:01 -0700</bug_when>
    <thetext>Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1772343</commentid>
    <comment_count>3</comment_count>
    <who name="">discuss</who>
    <bug_when>2021-06-24 10:21:29 -0700</bug_when>
    <thetext>I&apos;ve uploaded a patch that I&apos;m considering applying to the downstream macOS build of WebKitGTK in the Nix package manager for the time being. It seems to fix the problem, but I&apos;m not too sure whether this is a good idea or not. Would applying this patch have any obvious unintended side effects? Any help would be appreciated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1790042</commentid>
    <comment_count>4</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2021-09-02 20:37:21 -0700</bug_when>
    <thetext>(In reply to discuss from comment #3)
&gt; I&apos;ve uploaded a patch that I&apos;m considering applying to the downstream macOS
&gt; build of WebKitGTK in the Nix package manager for the time being. It seems
&gt; to fix the problem, but I&apos;m not too sure whether this is a good idea or not.
&gt; Would applying this patch have any obvious unintended side effects? Any help
&gt; would be appreciated.

It seems it has unintended side effects.

As far as I can see this patch made the WebKitGTK API tests to fail on the CI, check the red bubble above -&gt; https://ews-build.webkit.org/#/builders/34/builds/38608</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>432180</attachid>
            <date>2021-06-24 10:09:55 -0700</date>
            <delta_ts>2021-06-24 10:09:55 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-227360-20210625020953.patch</filename>
            <type>text/plain</type>
            <size>2071</size>
            <attacher>discuss</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjc5MTcyCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCmluZGV4IGUxMDdjZmUzYzA4MWVjMTAz
ODE5NzkyOWVmMzFjZTNmNjA1MzNjMjMuLmI4NzJlM2YxMWJmNWFiZDZkM2NkZTU0YjVhMDVmNmYw
M2JmYzEyNDAgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCisrKyBiL1NvdXJj
ZS9XZWJLaXQvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTYgQEAKKzIwMjEtMDYtMjQgIFNobyBZdWhh
cmEgIDxnaXRAbWlkY2hpbGRhbi5vcmc+CisKKyAgICAgICAgV2ViS2l0R1RLIGZhaWxzIHRvIGhh
bmRsZSBzb21lIGtleXByZXNzZXMgd2hlbiBidWlsdCB3aXRoIHRoZSBHVEsgUXVhcnR6IGJhY2tl
bmQgb24gbWFjT1MKKyAgICAgICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dp
P2lkPTIyNzM2MAorCisgICAgICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAg
ICAgIE5vIG5ldyB0ZXN0cyAoT09QUyEpLgorCisgICAgICAgICogVUlQcm9jZXNzL0FQSS9nbGli
L0lucHV0TWV0aG9kRmlsdGVyLmNwcDoKKyAgICAgICAgKFdlYktpdDo6SW5wdXRNZXRob2RGaWx0
ZXI6OmZp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bHRlcmluZ0NvbnRl
eHQucHJlZWRpdENoYW5nZWQgJiYgbV9jb21wb3NpdGlvblJlc3VsdC5sZW5ndGgoKSA9PSAxKQot
ICAgICAgICByZXR1cm4geyBmYWxzZSwgV1RGTW92ZShtX2NvbXBvc2l0aW9uUmVzdWx0KSB9Owot
CiAgICAgaWYgKCFwbGF0Zm9ybUV2ZW50S2V5SXNLZXlQcmVzcyhrZXlFdmVudCkpCiAgICAgICAg
IHJldHVybiB7IH07CiAKQEAgLTMyMiwxMCArMzE4LDYgQEAgdm9pZCBJbnB1dE1ldGhvZEZpbHRl
cjo6Y29tbWl0dGVkKGNvbnN0IGNoYXIqIGNvbXBvc2l0aW9uU3RyaW5nKQogCiAgICAgYXV0byog
d2ViVmlldyA9IHdlYmtpdElucHV0TWV0aG9kQ29udGV4dEdldFdlYlZpZXcobV9jb250ZXh0Lmdl
dCgpKTsKICAgICBBU1NFUlQod2ViVmlldyk7Ci0gICAgaWYgKG1fZmlsdGVyaW5nQ29udGV4dC5p
c0FjdGl2ZSkgewotICAgICAgICBpZiAoIW1fZmlsdGVyaW5nQ29udGV4dC5wcmVlZGl0Q2hhbmdl
ZCAmJiBwcmVlZGl0V2FzRW1wdHkgJiYgbV9jb21wb3NpdGlvblJlc3VsdC5sZW5ndGgoKSA9PSAx
KQotICAgICAgICAgICAgcmV0dXJuOwotICAgIH0KICAgICB3ZWJraXRXZWJWaWV3Q29uZmlybUNv
bXBvc2l0aW9uKHdlYlZpZXcsIG1fY29tcG9zaXRpb25SZXN1bHQpOwogICAgIG1fY29tcG9zaXRp
b25SZXN1bHQgPSB7IH07CiB9Cg==
</data>
<flag name="review"
          id="454146"
          type_id="1"
          status="?"
          setter="discuss"
    />
          </attachment>
      

    </bug>

</bugzilla>