ThinBridge / Chronos

Chromiumベースの業務ブラウザ
Other
5 stars 3 forks source link

Avoid exceptions at cef_log during shutting down #163

Closed HashidaTKS closed 6 months ago

HashidaTKS commented 6 months ago

Which issue(s) this PR fixes:

N/A

What this PR does / why we need it:

Exceptions may occur at cef_log during closing Chronos. The reason why the cef_log throws the exceptions seems that there leave some tasks for CEF. It seems better to call CefDoMessageLoopWork() multiple times on shutting down.

FYI: https://github.com/chromiumembedded/cef/blob/master/tests/shared/browser/main_message_loop_external_pump_win.cc#L93

How to verify the fixed issue:

The steps to verify:

Shutdown Chronos multiple times.

Expected result:

No exception occurs at cef_log during shutting down.

HashidaTKS commented 6 months ago

デバッグでVisual Studioから起動したChronosを閉じた際に、以下のcef_logで例外が発生することがある問題に対処。

LogMessage::~LogMessage() {
  std::string str_newline(stream_.str());
  cef_log(file_, line_, severity_, str_newline.c_str());
}

https://github.com/chromiumembedded/cef/blob/master/tests/shared/browser/main_message_loop_external_pump_win.cc#L93

上記のサンプルを眺めていて、現在のChronosでシャットダウン時のCefDoMessageLoopWork()が足りていないのではないかと思い、サンプルに倣い10回実行するように変更。 実際、この修正を入れるとシャットダウン時にcef_logでの例外が発生しなくなった。