<?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>311917</bug_id>
          
          <creation_ts>2026-04-10 01:38:25 -0700</creation_ts>
          <short_desc>[WPE][Qt6] WPEQtView emits a premature focus change that crashes input method plugins on mouse click</short_desc>
          <delta_ts>2026-04-10 01:51:44 -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>WPE WebKit</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Linux</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>Critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>aiswarya.kandoth</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2198728</commentid>
    <comment_count>0</comment_count>
      <attachid>478992</attachid>
    <who name="">aiswarya.kandoth</who>
    <bug_when>2026-04-10 01:38:25 -0700</bug_when>
    <thetext>Created attachment 478992
Complete backtrace while using a virtual keyboard with the Qt6 API.

WPEQtView::mousePressEvent() calls forceActiveFocus() unconditionally before checking whether m_webView is initialized. This causes Qt to emit a focusObjectChanged signal with the not yet ready web view as the new focus object. Input method plugin that receive this signal via QInputMethod::setFocusObject() may then attempt to inspect or cast the focus object and crash because of the uninitialized state.

Steps to reproduce:

1. Run the example minibrowser with the Qt6 API.
2. Add a Qt input method plugin (eg: virtual keyboard) with appropriate changes in QML (addition of InputPanel component in QML will be necessary).
3. Click on the view using a mouse before the web view is fully initialized.
4. Application crashes with a segmentation fault.

Relevant backtrace:

#8  WPEQtView::mousePressEvent(QMouseEvent*) ()
    from .../qt6/qml/org/wpewebkit/qtwpe/libqtwpe.so
#7  QQuickItem::forceActiveFocus(Qt::FocusReason) ()
#6  QQuickItem::setFocus(bool, Qt::FocusReason) ()
#5  QQuickDeliveryAgentPrivate::setFocusInScope(...)
#4  QWindow::focusObjectChanged(QObject*)        ← focus change emitted for uninitialized view
    → input method plugin crashes here


The complete backtrace produced when using a fork of cutekeyboard (https://github.com/amarula/cutekeyboard/tree/main) with an application using the Qt6 API is attached.


Note that the crash can be prevented inside an input method plugin itself using appropriate cast that tolerates unexpected object types, with qobject_cast in the case of cutekeyboard for example. However, the correct fix is not to emit the focus change prematurely.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2198731</commentid>
    <comment_count>1</comment_count>
    <who name="">aiswarya.kandoth</who>
    <bug_when>2026-04-10 01:51:44 -0700</bug_when>
    <thetext>Proposed fix : https://github.com/WebKit/WebKit/pull/62429</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>478992</attachid>
            <date>2026-04-10 01:38:25 -0700</date>
            <delta_ts>2026-04-10 01:38:25 -0700</delta_ts>
            <desc>Complete backtrace while using a virtual keyboard with the Qt6 API.</desc>
            <filename>backtrace-crash-on-mouse-press-libqtwpe.txt</filename>
            <type>text/plain</type>
            <size>1709</size>
            <attacher>aiswarya.kandoth</attacher>
            
              <data encoding="base64">VGhyZWFkIDEgIm1pbmlicm93c2VyIiByZWNlaXZlZCBzaWduYWwgU0lHU0VHViwgU2VnbWVudGF0
aW9uIGZhdWx0LgogIDB4YjA1YmE2ZjggaW4gX19keW5hbWljX2Nhc3QgKCkKICAgICBmcm9tIC91
c3IvbGliL2xpYnN0ZGMrKy5zby42CiAgKGdkYikgYnQgZn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