google / mozc

Mozc - a Japanese Input Method Editor designed for multi-platform
Other
2.39k stars 348 forks source link

A large number of mozc_renderer processes are launched. #912

Closed phoepsilonix closed 5 months ago

phoepsilonix commented 6 months ago

Description

A large number of mozc_renderer processes are launched. Depending on the timing, e.g. immediately after start-up, when a key is held down for a short period of time or a large amount of input is given while in conversion mode, a large number of mozc_renderer processes are launched. In this state, the conversion candidate window is not displayed.

Steps to reproduce

Depending on the timing, e.g. immediately after start-up, when a key is held down for a short period of time or a large amount of input is given while in conversion mode, a large number of mozc_renderer processes are launched. It is felt that the phenomenon of the conversion candidate window not being displayed is likely to occur when あ(a) is held down after typing あ(a) twice with あ(a) as a flap. At that time, a number of mozc_renderer are running at the same time.

Expected behavior

Only one mozc_renderer sub-process should be launched.

Actual behavior

In some cases, a large number of mozc_renderer processes are launched.

Screenshots

mozc_renderer_Multiple_Processes_Spawn

Version or commit-id

Mozc-2.29.5400.102+24.11.oss e8d25a2bee8ba5a7ac0c176cf8a8caef05663ddc

Environment

Investigations

Additional context

It may be reproducible depending on the timing of keystrokes.
It may be easier to reproduce in a heavy LiveISO environment.

hiroyuki-komatsu commented 5 months ago

Hi phoepsilonix, Thank you for your report.

Would you check if 0225743 has fixed the issue?

phoepsilonix commented 5 months ago

I have tried this, but it still does not seem to be sufficient. The same defects occurred with the 0225743 fix.

Having checked the fix, I would like to raise a point that I noticed.

I think the renderer is still running even if there are pending commands. RENDERERER_LAUNCHING would not be the only startup status. Shouldn't RENDERERER_READY also be included?

 if (Status() == RendererStatus::RENDERERER_READY ||
 Status() == RendererStatus::RENDERER_LAUNCHING) {

RENDERER_UNKNOWN is the default value. RENDERER_LAUNCHING RENDERER_READY RENDERER_TIMEOUT RENDERER_TERMINATED RENDERER_FATAL

TERMINATED is when the process terminates, probably due to external factors. FATAL is when Spawn fails.

RENDERER_LAUNCHING
RENDERER_READY
RENDERER_TIMEOUT

If the status is not in LAUNCHING, READY or TIMEOUT, then it is a good state to start mozc_renderer.

diff --git a/src/renderer/renderer_client.cc b/src/renderer/renderer_client.cc
index 885dcded5..a6958c4a4 100644
--- a/src/renderer/renderer_client.cc
+++ b/src/renderer/renderer_client.cc
@@ -106,8 +106,11 @@ class RendererLauncher : public RendererLauncherInterface {
       const std::string &name, const std::string &path,
       bool disable_renderer_path_check,
       IPCClientFactoryInterface *ipc_client_factory_interface) override {
-    if (Status() == RendererStatus::RENDERER_LAUNCHING) {
+    if (Status() == RendererStatus::RENDERER_LAUNCHING ||
+        Status() == RendererStatus::RENDERER_READY ||
+        Status() == RendererStatus::RENDERER_TIMEOUT) {
       // Renderer is already launching.
+      // The renderer is still up and running when in the pending command state.
       return;
     }
     SetStatus(RendererStatus::RENDERER_LAUNCHING);
phoepsilonix commented 5 months ago

I didn't give you the error log, so I'm attaching it.

E0407 13:59:12.543967    3070 ipc_path_manager.cc:105] IPCKey is invalid length
E0407 13:59:12.543982    3070 ipc_path_manager.cc:526] IPCServer::key is invalid
E0407 13:59:12.543994    3070 ipc_path_manager.cc:259] LoadPathName failed
E0407 13:59:12.544022    3070 ipc_path_manager.cc:105] IPCKey is invalid length
E0407 13:59:12.544026    3070 ipc_path_manager.cc:526] IPCServer::key is invalid
E0407 13:59:12.544032    3070 ipc_path_manager.cc:259] LoadPathName failed
W0407 13:59:12.544035    3070 renderer_client.cc:475] Discards a HIDE command since the renderer is not running
E0407 13:59:12.544303    3070 ipc_path_manager.cc:105] IPCKey is invalid length
E0407 13:59:12.544310    3070 ipc_path_manager.cc:526] IPCServer::key is invalid
E0407 13:59:12.544317    3070 ipc_path_manager.cc:259] LoadPathName failed
E0407 13:59:12.544337    3070 ipc_path_manager.cc:105] IPCKey is invalid length
E0407 13:59:12.544339    3070 ipc_path_manager.cc:526] IPCServer::key is invalid
E0407 13:59:12.544345    3070 ipc_path_manager.cc:259] LoadPathName failed
W0407 13:59:12.544347    3070 renderer_client.cc:475] Discards a HIDE command since the renderer is not running
E0407 13:59:12.546109    3070 ipc_path_manager.cc:105] IPCKey is invalid length
E0407 13:59:12.546123    3070 ipc_path_manager.cc:526] IPCServer::key is invalid
E0407 13:59:12.546132    3070 ipc_path_manager.cc:259] LoadPathName failed
E0407 13:59:12.546149    3070 ipc_path_manager.cc:105] IPCKey is invalid length
E0407 13:59:12.546152    3070 ipc_path_manager.cc:526] IPCServer::key is invalid
E0407 13:59:12.546160    3070 ipc_path_manager.cc:259] LoadPathName failed
W0407 13:59:12.546162    3070 renderer_client.cc:475] Discards a HIDE command since the renderer is not running
E0407 13:59:12.891520    3070 ipc_path_manager.cc:105] IPCKey is invalid length
E0407 13:59:12.891546    3070 ipc_path_manager.cc:526] IPCServer::key is invalid
E0407 13:59:12.891557    3070 ipc_path_manager.cc:259] LoadPathName failed
E0407 13:59:12.891578    3070 ipc_path_manager.cc:105] IPCKey is invalid length
E0407 13:59:12.891580    3070 ipc_path_manager.cc:526] IPCServer::key is invalid
E0407 13:59:12.891584    3070 ipc_path_manager.cc:259] LoadPathName failed
W0407 13:59:12.891587    3070 renderer_client.cc:479] cannot connect to renderer. restarting
E0407 13:59:13.092493    3076 ipc_path_manager.cc:105] IPCKey is invalid length
E0407 13:59:13.092513    3076 ipc_path_manager.cc:526] IPCServer::key is invalid
E0407 13:59:13.092521    3076 ipc_path_manager.cc:259] LoadPathName failed
E0407 13:59:13.092536    3076 ipc_path_manager.cc:105] IPCKey is invalid length
E0407 13:59:13.092537    3076 ipc_path_manager.cc:526] IPCServer::key is invalid
E0407 13:59:13.092541    3076 ipc_path_manager.cc:259] LoadPathName failed
E0407 13:59:13.092551    3076 unix_ipc.cc:309] Call failed: not connected
E0407 13:59:13.092552    3076 renderer_client.cc:83] Cannot send the request: 
phoepsilonix commented 5 months ago
diff --git a/src/renderer/renderer_client.cc b/src/renderer/renderer_client.cc
index 885dcded5..a6958c4a4 100644
--- a/src/renderer/renderer_client.cc
+++ b/src/renderer/renderer_client.cc
@@ -106,8 +106,11 @@ class RendererLauncher : public RendererLauncherInterface {
       const std::string &name, const std::string &path,
       bool disable_renderer_path_check,
       IPCClientFactoryInterface *ipc_client_factory_interface) override {
-    if (Status() == RendererStatus::RENDERER_LAUNCHING) {
+    if (Status() == RendererStatus::RENDERER_LAUNCHING ||
+        Status() == RendererStatus::RENDERER_READY ||
+        Status() == RendererStatus::RENDERER_TIMEOUT) {
       // Renderer is already launching.
+      // The renderer is still up and running when in the pending command state.
       return;
     }
     SetStatus(RendererStatus::RENDERER_LAUNCHING);

I have prepared a live ISO with the above fixes. I have restarted the live ISO several times and the problem does not seem to occur.