Closed HashidaTKS closed 9 months ago
メモ:
Windows 11で、右上のxボタンなどからChronosを終了しても、Chronosのプロセスが残留する問題が起きていた(確かに手元でも発生していたのだが、問題だと気付いていなかった...)。説明欄に記載の通り、この修正によりその問題も直っている様子。
external_message_pump
をtrue
にしたことにより、アプリケーション独自のメッセージがCEFにも伝わるようになった(という認識な)ので、上記の問題が直るのも納得がいく。
確かに...。
https://github.com/ThinBridge/Chronos/blob/master/Sazabi.cpp#L1644
上記の;;MessageBoxを通っているが、メッセージボックスが表示されずにIDYESが返ってくる。 終了しようとしていることを理解して、ダイアログを表示しないようになってしまっているのだろうか...。
https://github.com/ThinBridge/Chronos/blob/master/MainFrm.cpp#L353 https://github.com/ThinBridge/Chronos/blob/master/Sazabi.cpp#L140
同様にMessageBox
関係でHWND
にNULL
を指定している場所は上記の場所があったが、これらの場所では問題なく動作している。
問題が発生するのはExitするときだけの模様。
動作自体は確かに期待通りになる。
MB_DEFAULT_DESKTOP_ONLY
をなぜ追加したかについての説明をSazabi.cppのコードのコメントとしていれておいたほうがよさそうである。
ありがとうございます。コメントを追加しました。 また、コミットを一つにまとめました。
https://www.codeproject.com/Articles/35209/MessageBox-in-ExitInstance
WM_QUIT
がメッセージキューの中にいると、新しいダイアログが作成されないというMFCの仕様とのこと。
ExitInstance
関数の中がまさにそのような状況で、今回のケースに該当している。
external_message_pump
をtrue
にしたことで、メッセージの伝達順序が変わった等でこの状況になるようになったのだろう
(恐らく変更前の状態がMFC的におかしいのではないか)。
MB_DEFAULT_DESKTOP_ONLY
やMB_SERVICE_NOTIFICATION
が指定された場合、現在のウィンドウに紐づかないと解釈されて、現在のウィンドウのWM_QUIT
も無視して動くのかなぁ。
上記の例のようにWM_QUIT
をメッセージキューから除外する方がよいのだろうか。
WM_QUIT
を読み飛ばすようにすることでもダイアログが表示されるようになることは確認済み。
間違って https://github.com/ThinBridge/Chronos-SG/issues/119 に書いてしまったので転載。
cef_settings_t.multi_threaded_message_loopの説明に書かれている
CefBrowserProcessHandler::OnScheduleMessagePumpWork()
を実装していないのが気になるところです。あまり実装例が見つからないのですが、CefSharpの例はこんな感じでした
protected override void OnScheduleMessagePumpWork(long delay) { //If the delay is greater than the Maximum then use ThirtyTimesPerSecond //instead - we do this to achieve a minimum number of FPS if (delay > ThirtyTimesPerSecond) { delay = ThirtyTimesPerSecond; } //When delay <= 0 we'll execute Cef.DoMessageLoopWork immediately // if it's greater than we'll just let the Timer which fires 30 times per second // care of the call if (delay <= 0) { dispatcher.BeginInvoke((Action)(() => Cef.DoMessageLoopWork()), DispatcherPriority.Normal); } }
Chronosでやるとしたら、正の値の
delay
が来たらその時間だけCefDoMessageLoopWork()
の呼び出しをスキップする? これを実装することでMessageBox
の件が改善するのかしないのか、気になるところです。
上記の
Chronosでやるとしたら、正の値の
delay
が来たらその時間だけCefDoMessageLoopWork()
の呼び出しをスキップする? これを実装することでMessageBox
の件が改善するのかしないのか、気になるところです。
はちょっと違うかなぁと後になって思った。 CefSharpと似たような感じにすべきか。 メッセージループのところを抜本的に見直した方が良いかもしれない。
ただ、今回のリリースでそこまでやるのは無理なので、
すごく黒魔術感あるので @ashie さんの判断も待ちたい。
現状ではすぐには判断つかないなぁと思ってたのですが、ある程度メカニズムが解明されて、通しテストの結果が良好なのであれば応急処置としては現状でマージしても良いのかなと思い始めてます。
いずれにしてもメッセージループの根本的なところに手を入れるので、他の箇所で思わぬデグレが発生する可能性もあると思います。なので入念に通しテストをした方が良さそうです。
ありがとうございます。
OnScheduleMessagePumpWork
は既存の存在するものが呼び出されるというような解釈をしていたのですが、自分で実装しなければいけないのですね。。。ちゃんと確認すべきでした。
RC4に投入することになった。
Which issue(s) this PR fixes:
https://github.com/ThinBridge/Chronos-SG/issues/119
What this PR does / why we need it:
Set CEF's
external_message_pump
settingTRUE
.This patch fixes a bug that shortcut keys like "Ctrl + N (new tab)" don't work on Windows 11. Also, this patch fixes a bug that a Chronos process is left after exiting on Windows 11.
https://cef-builds.spotifycdn.com/docs/119.1/structcef__settings__t.html#af11b432414c7002991e3b6ae9b2f1f07
This is the case for us.
How to verify the fixed issue:
The steps to verify:
Expected result: