Does Cef messge loop work with WM only?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Does Cef messge loop work with WM only?

Postby Teotihuacan » Thu Jul 16, 2020 6:03 am

I use MsgWaitForMultipleObjects in my main loop
and I call CefDoMessageLoopWork only if WM_XXXX messages received no matter it's for Cef or for my other components (since Cef doesn't provide a way to distinguish one from another)

but there also could be events(CreateEvent) that Cef uses for itself but my loop doesn't take them into account - or Cef doesn't use them?
Teotihuacan
Techie
 
Posts: 48
Joined: Sun Sep 09, 2018 6:23 am

Re: Does Cef messge loop work with WM only?

Postby ndesktop » Thu Jul 16, 2020 9:20 am

CefDoMessageLoopWork uses a run loop object with RunUntilIdle.
This one does
Code: Select all
void RunLoop::RunUntilIdle() {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

  quit_when_idle_received_ = true;
  Run();
}
...
void RunLoop::Run() {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

  if (!BeforeRun())
    return;

  // If there is a RunLoopTimeout active then set the timeout.
  // TODO(crbug.com/905412): Use real-time for Run() timeouts so that they
  // can be applied even in tests which mock TimeTicks::Now().
  CancelableOnceClosure cancelable_timeout;
  const RunLoopTimeout* run_timeout = GetTimeoutForCurrentThread();
  if (run_timeout) {
    cancelable_timeout.Reset(
        BindOnce(&OnRunLoopTimeout, Unretained(this), run_timeout->on_timeout));
    origin_task_runner_->PostDelayedTask(
        FROM_HERE, cancelable_timeout.callback(), run_timeout->timeout);
  }

  DCHECK_EQ(this, delegate_->active_run_loops_.top());
  const bool application_tasks_allowed =
      delegate_->active_run_loops_.size() == 1U ||
      type_ == Type::kNestableTasksAllowed;
  delegate_->Run(application_tasks_allowed, TimeDelta::Max());

  AfterRun();
}


So basically it calls delegate_->Run, which ends up in libcef win32 in MainMessageLoopMultithreadedWin::Run().
This is a regular GetMessageLoop and does not have events. But is also not exposed upper to you can plug in your own MWMO.

I'd say your MWMO is good now, but watch the source tree. Not sure how cef can expose the loop object in a way that you might intermix it with your custom one.
ndesktop
Master
 
Posts: 756
Joined: Thu Dec 03, 2015 10:10 am

Re: Does Cef messge loop work with WM only?

Postby Teotihuacan » Sat Jul 18, 2020 3:35 pm

Ive found that CefDoMessageLoopWork doesnt workd for me cause sometimes message processing gets hung up inside this function and so not letting my message processing code to do its work
Teotihuacan
Techie
 
Posts: 48
Joined: Sun Sep 09, 2018 6:23 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 53 guests