Repository: electron/electron (language: cpp)

Issue:
[Bug]: Crash with `enable-wayland-ime` parameters on Linux
### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [x] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

24.x.y

### What operating system are you using?

Other Linux

### Operating System Version

Including but not limited to Arch Linux

### What arch are you using?

x64

### Last Known Working Electron version

_No response_

### Expected Behavior

Applications launch normally.

### Actual Behavior

As soon as I type using the input method, the application crashes

### Testcase Gist URL

_No response_

### Additional Information

Some of my applications like [drawio-desktop](https://github.com/jgraph/drawio-desktop) are using electron 24, which is based on chromium 112. However there is  a bug in chromium 112, see [Chromium crashes when running with `--ozone-platform=wayland --enable-wayland-ime` under weston/kwin](https://bugs.chromium.org/p/chromium/issues/detail?id=1431532), which make electron applications crash immediately when launching them with `--enable-wayland-ime` . I have to launch the applications in xwayland mode.

Although the [patchset](https://chromium-review.googlesource.com/c/chromium/src/+/4423030) has been merged into the mainline of chromium, the chromium 112 is no longer supported, so they won't backport the patchset to 112. I wonder if the patchset can be merged into electron 24 to fix this problem.


Discussion / hints:
Any update?

Fix patch:
diff --git a/patches/chromium/.patches b/patches/chromium/.patches
index a7978b61c1dd8..b3a03f7e1b5b9 100644
--- a/patches/chromium/.patches
+++ b/patches/chromium/.patches
@@ -128,3 +128,4 @@ fix_x11_window_restore_minimized_maximized_window.patch
 chore_defer_usb_service_getdevices_request_until_usb_service_is.patch
 revert_x11_keep_windowcache_alive_for_a_time_interval.patch
 cherry-pick-ec53103cc72d.patch
+cherry-pick-94af9d13a14b.patch
diff --git a/patches/chromium/cherry-pick-94af9d13a14b.patch b/patches/chromium/cherry-pick-94af9d13a14b.patch
new file mode 100644
index 0000000000000..f205cffba27e6
--- /dev/null
+++ b/patches/chromium/cherry-pick-94af9d13a14b.patch
@@ -0,0 +1,35 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Ivan Pavlotsky <ivan.pavlotsky@lge.com>
+Date: Mon, 1 May 2023 07:48:23 +0000
+Subject: Check nullptr in ZWPTextInputWrapperV1::Activate()
+
+After the CL https://crrev.com/c/4160118 a crash occurres on the
+wl::get_version_of_object() call in ZWPTextInputWrapperV1::Activate()
+when |ZWPTextInputWrapperV1::extended_obj_| is not set.
+
+Added nullptr check to fix it.
+
+Bug: b:251677220, 1431532
+Change-Id: Ia5606f1c0d08f552f1091b2a9350655f4bdac939
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4423030
+Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
+Reviewed-by: Maksim Sisov <msisov@igalia.com>
+Commit-Queue: Maksim Sisov <msisov@igalia.com>
+Cr-Commit-Position: refs/heads/main@{#1137771}
+
+diff --git a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.cc b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.cc
+index d577ac4f822901340281c48bc754425484f28f48..b9e508824c7cb17c0673007532f88242a99fa5df 100644
+--- a/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.cc
++++ b/ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.cc
+@@ -156,8 +156,9 @@ void ZWPTextInputWrapperV1::Reset() {
+ void ZWPTextInputWrapperV1::Activate(WaylandWindow* window,
+                                      TextInputClient::FocusReason reason) {
+   DCHECK(connection_->seat());
+-  if (wl::get_version_of_object(extended_obj_.get()) >=
+-      ZCR_EXTENDED_TEXT_INPUT_V1_SET_FOCUS_REASON_SINCE_VERSION) {
++  if (extended_obj_.get() &&
++      wl::get_version_of_object(extended_obj_.get()) >=
++          ZCR_EXTENDED_TEXT_INPUT_V1_SET_FOCUS_REASON_SINCE_VERSION) {
+     absl::optional<uint32_t> wayland_focus_reason;
+     switch (reason) {
+       case ui::TextInputClient::FocusReason::FOCUS_REASON_NONE:


Test patch: