Windows C Client with its own window procedure

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.

Windows C Client with its own window procedure

Postby oberrocker » Tue Dec 05, 2017 10:13 am

Following the C-client example here: https://github.com/cztomczak/cefcapi I created a Windows version that uses its own window procedure. This is a requirement for my project, since the main window must be "chromeless" (no frame) but still be movable - among other things.

My approach is basically to set cef_window_info_t's parent_window to my main window's handle (HWND) and set multi_threaded_message_loop in cef_settings_t to 1.

However, the program crashes with an empty main window. I get a "check failed" message in thread_restrictions.cc (which belongs to Chromium itself, I guess) stating "Function marked as IO-only was called from a thread that disallows UI!"

My source code can be found here: https://github.com/m-thielen/cefcapi/bl ... msg_loop.c

Is there anything I miss?

Thanks,
Markus
oberrocker
Newbie
 
Posts: 6
Joined: Tue Dec 05, 2017 9:49 am

Re: Windows C Client with its own window procedure

Postby magreenblatt » Tue Dec 05, 2017 12:23 pm

What is the full symbolized call stack for the crash?
magreenblatt
Site Admin
 
Posts: 12384
Joined: Fri May 29, 2009 6:57 pm

Re: Windows C Client with its own window procedure

Postby oberrocker » Tue Dec 05, 2017 2:08 pm

[Inline Frame] libcef.dll!base::debug::BreakDebugger() Line 21 C++ Symbols loaded.
libcef.dll!logging::LogMessage::~LogMessage() Line 791 C++ Symbols loaded.
libcef.dll!base::ThreadRestrictions::AssertIOAllowed() Line 46 C++ Symbols loaded.
libcef.dll!base::MakeAbsoluteFilePath(const base::FilePath & input) Line 87 C++ Symbols loaded.
libcef.dll!base::PathService::Get(int key, base::FilePath * result) Line 222 C++ Symbols loaded.
libcef.dll!content::PathProvider(int key, base::FilePath * result) Line 20 C++ Symbols loaded.
libcef.dll!base::PathService::Get(int key, base::FilePath * result) Line 211 C++ Symbols loaded.
libcef.dll!content::ChildProcessHost::GetChildPath(int flags) Line 77 C++ Symbols loaded.
libcef.dll!content::GpuProcessHost::LaunchGpuProcess() Line 1007 C++ Symbols loaded.
libcef.dll!content::GpuProcessHost::Init() Line 622 C++ Symbols loaded.
libcef.dll!content::GpuProcessHost::Get(content::GpuProcessHost::GpuProcessKind kind, bool force_create) Line 403 C++ Symbols loaded.
libcef.dll!content::BrowserGpuChannelHostFactory::EstablishRequest::EstablishOnIO() Line 106 C++ Symbols loaded.
libcef.dll!base::internal::Invoker<base::internal::BindState<void (__thiscall content::BrowserGpuChannelHostFactory::EstablishRequest::*)(void),scoped_refptr<content::BrowserGpuChannelHostFactory::EstablishRequest> >,void __cdecl(void)>::RunOnce(base::internal::BindStateBase * base) Line 318 C++ Symbols loaded.
[Inline Frame] libcef.dll!base::OnceCallback<void __cdecl(void)>::Run() Line 64 C++ Symbols loaded.
libcef.dll!base::debug::TaskAnnotator::RunTask(const char * queue_function, base::PendingTask * pending_task) Line 65 C++ Symbols loaded.
libcef.dll!base::MessageLoop::RunTask(base::PendingTask * pending_task) Line 407 C++ Symbols loaded.
[Inline Frame] libcef.dll!base::MessageLoop::DeferOrRunPendingTask(base::PendingTask) Line 417 C++ Symbols loaded.
libcef.dll!base::MessageLoop::DoWork() Line 524 C++ Symbols loaded.
libcef.dll!base::MessagePumpForIO::DoRunLoop() Line 483 C++ Symbols loaded.
libcef.dll!base::MessagePumpWin::Run(base::MessagePump::Delegate * delegate) Line 58 C++ Symbols loaded.
libcef.dll!base::MessageLoop::Run() Line 347 C++ Symbols loaded.
libcef.dll!base::RunLoop::Run() Line 124 C++ Symbols loaded.
libcef.dll!base::Thread::Run(base::RunLoop * run_loop) Line 256 C++ Symbols loaded.
libcef.dll!content::BrowserThreadImpl::IOThreadRun(base::RunLoop * run_loop) Line 279 C++ Symbols loaded.
libcef.dll!content::BrowserThreadImpl::Run(base::RunLoop * run_loop) Line 313 C++ Symbols loaded.
libcef.dll!base::Thread::ThreadMain() Line 341 C++ Symbols loaded.
libcef.dll!base::`anonymous namespace'::ThreadFunc(void * params) Line 91 C++ Symbols loaded.
oberrocker
Newbie
 
Posts: 6
Joined: Tue Dec 05, 2017 9:49 am

Re: Windows C Client with its own window procedure

Postby oberrocker » Tue Dec 05, 2017 2:16 pm

This is the complete message that was logged:

Code: Select all
[1205/200355.869:FATAL:thread_restrictions.cc(38)] Check failed: false. Function marked as IO-only was called from a thread that disallows IO!  If this thread really should be allowed to make IO calls, adjust the call to base::ThreadRestrictions::SetIOAllowed() in this thread's startup.  If this task is running inside the TaskScheduler, the TaskRunner used to post it needs to have MayBlock() in its TaskTraits.
oberrocker
Newbie
 
Posts: 6
Joined: Tue Dec 05, 2017 9:49 am

Re: Windows C Client with its own window procedure

Postby magreenblatt » Tue Dec 05, 2017 2:36 pm

magreenblatt
Site Admin
 
Posts: 12384
Joined: Fri May 29, 2009 6:57 pm

Re: Windows C Client with its own window procedure

Postby oberrocker » Tue Dec 05, 2017 3:34 pm

Ok, quite misleading. But launching the exe outside of Visual Studio leads to a crash, too. Just in time debugging in Visual Studio then shows the following call stack:

> msctf.dll!747960c8() Unknown Non-user code. Cannot find or open the PDB file.
[Frames below may be incorrect and/or missing, no symbols loaded for msctf.dll] Annotated Frame
[Inline Frame] libcef.dll!base::internal::FunctorTraits<void (__cdecl*)(`anonymous namespace'::CreateBrowserHelper *),void>::Invoke(void(*)(`anonymous-namespace'::CreateBrowserHelper *)) Line 149 C++ Symbols loaded.
[Inline Frame] libcef.dll!base::internal::InvokeHelper<0,void>::MakeItSo(void(*)(`anonymous-namespace'::CreateBrowserHelper *) &) Line 277 C++ Symbols loaded.
libcef.dll!base::internal::Invoker<base::internal::BindState<void (__cdecl*)(`anonymous namespace'::CreateBrowserHelper *),A0xea5941fb::CreateBrowserHelper *>,void __cdecl(void)>::RunImpl<void (__cdecl*const &)(`anonymous namespace'::CreateBrowserHelper *),std::tuple<`anonymous namespace'::CreateBrowserHelper *> const &,0>(void(*)(`anonymous-namespace'::CreateBrowserHelper *) & functor, const std::tuple<`anonymous namespace'::CreateBrowserHelper *> & bound, std::integer_sequence<unsigned int,0> __formal) Line 349 C++ Symbols loaded.
libcef.dll!base::internal::Invoker<base::internal::BindState<void (__cdecl*)(`anonymous namespace'::CreateBrowserHelper *),A0xea5941fb::CreateBrowserHelper *>,void __cdecl(void)>::Run(base::internal::BindStateBase * base) Line 331 C++ Symbols loaded.
[Inline Frame] libcef.dll!base::OnceCallback<void __cdecl(void)>::Run() Line 64 C++ Symbols loaded.
libcef.dll!base::debug::TaskAnnotator::RunTask(const char * queue_function, base::PendingTask * pending_task) Line 65 C++ Symbols loaded.
libcef.dll!base::MessageLoop::RunTask(base::PendingTask * pending_task) Line 407 C++ Symbols loaded.
[Inline Frame] libcef.dll!base::MessageLoop::DeferOrRunPendingTask(base::PendingTask) Line 417 C++ Symbols loaded.
libcef.dll!base::MessageLoop::DoWork() Line 524 C++ Symbols loaded.
libcef.dll!base::MessagePumpForUI::DoRunLoop() Line 174 C++ Symbols loaded.
libcef.dll!base::MessagePumpWin::Run(base::MessagePump::Delegate * delegate) Line 58 C++ Symbols loaded.
libcef.dll!base::MessageLoop::Run() Line 347 C++ Symbols loaded.
libcef.dll!base::RunLoop::Run() Line 124 C++ Symbols loaded.
libcef.dll!base::Thread::Run(base::RunLoop * run_loop) Line 256 C++ Symbols loaded.
libcef.dll!base::Thread::ThreadMain() Line 341 C++ Symbols loaded.
libcef.dll!base::`anonymous namespace'::ThreadFunc(void * params) Line 91 C++ Symbols loaded.
[External Code] Annotated Frame
oberrocker
Newbie
 
Posts: 6
Joined: Tue Dec 05, 2017 9:49 am

Re: Windows C Client with its own window procedure

Postby magreenblatt » Tue Dec 05, 2017 3:49 pm

Your `cef_client_t client` is stack allocated in init_cef_window. It should be heap allocated instead and the lifespan should be managed as described at https://bitbucket.org/chromiumembedded/ ... TheCAPI.md
magreenblatt
Site Admin
 
Posts: 12384
Joined: Fri May 29, 2009 6:57 pm

Re: Windows C Client with its own window procedure

Postby oberrocker » Wed Dec 06, 2017 1:37 am

Oops - I never looked at the ref counting implementation of the cefcapi example; it is just a dummy implementation!

What I don't understand though is why cef_base_ref_counted_t in cef_base_capi.h does not contain the reference counter itself (I mean an unsigned int or whatever that actually stores the count). What could be a better place?

Thanks a lot!
oberrocker
Newbie
 
Posts: 6
Joined: Tue Dec 05, 2017 9:49 am

Re: Windows C Client with its own window procedure

Postby magreenblatt » Wed Dec 06, 2017 11:16 am

The C API is a wrapper for the C++ API internally so the ref-count needs to be communicated via function calls.
magreenblatt
Site Admin
 
Posts: 12384
Joined: Fri May 29, 2009 6:57 pm

Re: Windows C Client with its own window procedure

Postby oberrocker » Wed Dec 06, 2017 2:54 pm

Sure, but this way one has to create and maintain an array of reference counters variables for all objects in use...
oberrocker
Newbie
 
Posts: 6
Joined: Tue Dec 05, 2017 9:49 am

Next

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot], salvadordf and 53 guests