Browse Source

fix: fix TSF hang when using non-English IMEs (#42249)

fix: cherry-pick TSF hang revert for DPI changes

This reverts Chrome commit 9577a678355605656c7664e6367b0144948dad84.
Keeley Hammond 11 months ago
parent
commit
0416b11529

+ 1 - 0
patches/chromium/.patches

@@ -132,3 +132,4 @@ fix_add_support_for_skipping_first_2_no-op_refreshes_in_thumb_cap.patch
 refactor_expose_file_system_access_blocklist.patch
 cherry-pick-013961609785.patch
 feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch
+revert_fix_ime_prevent_tsf_hang_chromium_window_when_dpi_changed.patch

+ 72 - 0
patches/chromium/revert_fix_ime_prevent_tsf_hang_chromium_window_when_dpi_changed.patch

@@ -0,0 +1,72 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Keeley Hammond <[email protected]>
+Date: Wed, 22 May 2024 11:05:46 -0700
+Subject: Revert "fix: ime: Prevent TSF hang Chromium window when DPI changed"
+
+This reverts commit 9577a678355605656c7664e6367b0144948dad84.
+
+Reason for revert: This causes performance issues while typing and hangs the browser. See https://issues.chromium.org/issues/328859185#comment10
+
+diff --git a/ui/base/ime/init/input_method_initializer.cc b/ui/base/ime/init/input_method_initializer.cc
+index bddb5c062a89f69a59a5a58dda36ef720fee9592..a500669ac54e79f433b9fbf5292dd37a1c7ae57a 100644
+--- a/ui/base/ime/init/input_method_initializer.cc
++++ b/ui/base/ime/init/input_method_initializer.cc
+@@ -32,16 +32,6 @@ void ShutdownInputMethod() {
+ #endif
+ }
+ 
+-void RestartInputMethod() {
+-#if !BUILDFLAG(IS_CHROMEOS_ASH) && BUILDFLAG(IS_WIN)
+-  // Some tests don't have a TSFBridge and may cause error if we set one.
+-  if (TSFBridge::GetInstance()) {
+-    TSFBridge::Shutdown();
+-    TSFBridge::Initialize();
+-  }
+-#endif
+-}
+-
+ void InitializeInputMethodForTesting() {
+ #if defined(USE_AURA) && BUILDFLAG(IS_LINUX)
+   GetInputMethodContextFactoryForTest() =
+diff --git a/ui/base/ime/init/input_method_initializer.h b/ui/base/ime/init/input_method_initializer.h
+index ef14c6e3d8f5ccbb58b079e2bbfa1d9f20ab8931..358bdc9a4188b7d910af6f7d308df5f38d35715b 100644
+--- a/ui/base/ime/init/input_method_initializer.h
++++ b/ui/base/ime/init/input_method_initializer.h
+@@ -17,10 +17,6 @@ COMPONENT_EXPORT(UI_BASE_IME_INIT) void InitializeInputMethod();
+ // called in the UI thread after input method is used.
+ COMPONENT_EXPORT(UI_BASE_IME_INIT) void ShutdownInputMethod();
+ 
+-// https://crbug.com/41486958
+-// Prevent TSF from hanging on Windows, for details read links above.
+-COMPONENT_EXPORT(UI_BASE_IME_INIT) void RestartInputMethod();
+-
+ // Initializes thread-local resources for input method. This function is
+ // intended to be called from Setup function of unit tests.
+ COMPONENT_EXPORT(UI_BASE_IME_INIT) void InitializeInputMethodForTesting();
+diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
+index 6f638b2003ff86bc06bd82402ab358dfb61c58b7..af1855545cf2892c89f4d218f3bacfd9a57e0bb5 100644
+--- a/ui/views/win/hwnd_message_handler.cc
++++ b/ui/views/win/hwnd_message_handler.cc
+@@ -37,7 +37,6 @@
+ #include "ui/accessibility/platform/ax_fragment_root_win.h"
+ #include "ui/accessibility/platform/ax_platform_node_win.h"
+ #include "ui/accessibility/platform/ax_system_caret_win.h"
+-#include "ui/base/ime/init/input_method_initializer.h"
+ #include "ui/base/ime/text_input_client.h"
+ #include "ui/base/ime/text_input_type.h"
+ #include "ui/base/ui_base_features.h"
+@@ -1874,14 +1873,6 @@ LRESULT HWNDMessageHandler::OnDpiChanged(UINT msg,
+   SetBoundsInternal(gfx::Rect(*reinterpret_cast<RECT*>(l_param)), false);
+   delegate_->HandleWindowScaleFactorChanged(scaling_factor);
+ 
+-  // https://crbug.com/41486958
+-  // On Windows, TSF will hang the browser window and stuck KEYBOARD and MOUSE
+-  // window messages when user is using a non-English IME (Chinese: Microsoft
+-  // Pinyin, etc..) and try typing on any textarea after a DPI change when
+-  // window is minimized. This hacky workaround fix that problem, as same
+-  // reproduce procedure no longer triggers the hang.
+-  ui::RestartInputMethod();
+-
+   return 0;
+ }
+