Fatal crash with custom scheme

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.

Fatal crash with custom scheme

Postby somebodyy » Tue Aug 25, 2015 6:10 pm

Hi,

basically I'm running into the same problem as posted here http://magpcss.org/ceforum/viewtopic.php?f=6&t=10604&p=16450&hilit=Error+deserializing+message#p16450.
Unfortunately, the last post in the linked thread says
dreijer wrote:Solution: Turns out that custom schemes should be registered in both the browser process and all sub-processes.

of what I have no idea how to do it.

I am modifying the cefsimple example and so far have made the following changes: (it's in patch format which you can apply using
Code: Select all
patch -p1 diff.txt
from inside the cefsimple folder. I compared my changes to the custom scheme implementation in the cefclient example and couldn't spot major differences.

Code: Select all
diff --git a/MySchemeHandlerFactory.cpp b/MySchemeHandlerFactory.cpp
index d13f704..07d8310 100644
--- a/MySchemeHandlerFactory.cpp
+++ b/MySchemeHandlerFactory.cpp
@@ -32,20 +32,20 @@
 #include "cefclient/browser/test_runner.h"
 
 #include "MySchemeHandlerFactory.h"
-           
-           
+
+
 // Implementation of the schema handler for client:// requests.
             class ClientSchemeHandler : public CefResourceHandler {
             public:
                 ClientSchemeHandler() : offset_(0) {}
-               
+
                 virtual bool ProcessRequest(CefRefPtr<CefRequest> request,
                                             CefRefPtr<CefCallback> callback)
                 OVERRIDE {
                     CEF_REQUIRE_IO_THREAD();
-                   
+
                     bool handled = false;
-                   
+
                     std::string url = request->GetURL();
                     if (url == "client://example/index.html") {
                         std::ifstream ifs("/Users/svkurowski/Projects/headless-webgl/example/index.html");
@@ -59,20 +59,20 @@
                         "ClientSchemeHandler class handling the client:// protocol."
                         "<br/>You should see an image:"
                         "<br/><img src=\"client://tests/logo.png\"><pre>";
-                       
+
                         // Output a string representation of the request
                         //const std::string& dump = test_runner::DumpRequestContents(request);
                         //data_.append(dump);
-                       
+
                         data_.append("</pre><br/>Try the test form:"
                                      "<form method=\"POST\" action=\"handler.html\">"
                                      "<input type=\"text\" name=\"field1\">"
                                      "<input type=\"text\" name=\"field2\">"
                                      "<input type=\"submit\">"
                                      "</form></body></html>");*/
-                       
+
                         handled = true;
-                       
+
                         // Set the resulting mime type
                         mime_type_ = "text/html";
                     } else if (url == "client://example/images") {/*
@@ -86,66 +86,66 @@
                         handled = true;
                         mime_type_ = "text/html";
                     }
-                   
+
                     if (handled) {
                         // Indicate the headers are available.
                         callback->Continue();
                         return true;
                     }
-                   
+
                     return false;
                 }
-               
+
                 virtual void GetResponseHeaders(CefRefPtr<CefResponse> response,
                                                 int64& response_length,
                                                 CefString& redirectUrl) OVERRIDE {
                     CEF_REQUIRE_IO_THREAD();
-                   
+
                     DCHECK(!data_.empty());
-                   
+
                     response->SetMimeType(mime_type_);
                     response->SetStatus(200);
-                   
+
                     // Set the resulting response length
                     response_length = data_.length();
                 }
-               
+
                 virtual void Cancel() OVERRIDE {
                     CEF_REQUIRE_IO_THREAD();
                 }
-               
+
                 virtual bool ReadResponse(void* data_out,
                                           int bytes_to_read,
                                           int& bytes_read,
                                           CefRefPtr<CefCallback> callback)
                 OVERRIDE {
                     CEF_REQUIRE_IO_THREAD();
-                   
+
                     bool has_data = false;
                     bytes_read = 0;
-                   
+
                     if (offset_ < data_.length()) {
                         // Copy the next block of data into the buffer.
                         int transfer_size =
                         std::min(bytes_to_read, static_cast<int>(data_.length() - offset_));
                         memcpy(data_out, data_.c_str() + offset_, transfer_size);
                         offset_ += transfer_size;
-                       
+
                         bytes_read = transfer_size;
                         has_data = true;
                     }
-                   
+
                     return has_data;
                 }
-               
+
             private:
                 std::string data_;
                 std::string mime_type_;
                 size_t offset_;
-               
+
                 IMPLEMENT_REFCOUNTING(ClientSchemeHandler);
             };
-           
+
             // Implementation of the factory for for creating schema handlers.
             class MySchemeHandlerFactory : public CefSchemeHandlerFactory {
             public:
@@ -158,11 +158,10 @@
                     CEF_REQUIRE_IO_THREAD();
                     return new ClientSchemeHandler();
                 }
-               
+
                 IMPLEMENT_REFCOUNTING(MySchemeHandlerFactory);
             };
 
 void RegisterSchemeHandlers() {
     CefRegisterSchemeHandlerFactory("client", "", new MySchemeHandlerFactory());
 }
-


The output of the program is the following:
Code: Select all
[0826/005544:WARNING:dns_config_service_posix.cc(146)] dns_config has unhandled options!
[0826/005545:INFO:url_request_manager.cc(278)] CefURLRequestManager hit for client://example/index.html
[0826/005545:FATAL:ipc_message_utils.h(1031)] Check failed: false. Error deserializing message 132550
0   Chromium Embedded Framework         0x000000010071db6f base::debug::StackTrace::StackTrace() + 47
1   Chromium Embedded Framework         0x000000010071dbc3 base::debug::StackTrace::StackTrace() + 35
2   Chromium Embedded Framework         0x000000010076b733 logging::LogMessage::~LogMessage() + 67
3   Chromium Embedded Framework         0x000000010076a673 logging::LogMessage::~LogMessage() + 35
4   Chromium Embedded Framework         0x0000000106954101 bool IPC::SyncMessageSchema<base::Tuple<int, GURL, content::ThreeDAPIType>, base::Tuple<bool&> >::DispatchWithSendParams<content::RenderMessageFilter, content::RenderMessageFilter, void (content::RenderMessageFilter::*)(int, GURL const&, content::ThreeDAPIType, bool*)>(bool, base::Tuple<int, GURL, content::ThreeDAPIType> const&, IPC::Message const*, content::RenderMessageFilter*, content::RenderMessageFilter*, void (content::RenderMessageFilter::*)(int, GURL const&, content::ThreeDAPIType, bool*)) + 401
5   Chromium Embedded Framework         0x0000000106949783 bool ViewHostMsg_Are3DAPIsBlocked::Dispatch<content::RenderMessageFilter, content::RenderMessageFilter, void, void (content::RenderMessageFilter::*)(int, GURL const&, content::ThreeDAPIType, bool*)>(IPC::Message const*, content::RenderMessageFilter*, content::RenderMessageFilter*, void*, void (content::RenderMessageFilter::*)(int, GURL const&, content::ThreeDAPIType, bool*)) + 243
6   Chromium Embedded Framework         0x000000010694125b content::RenderMessageFilter::OnMessageReceived(IPC::Message const&) + 7371
7   Chromium Embedded Framework         0x0000000105ed27cc content::BrowserMessageFilter::Internal::DispatchMessage(IPC::Message const&) + 108
8   Chromium Embedded Framework         0x0000000105ed2225 content::BrowserMessageFilter::Internal::OnMessageReceived(IPC::Message const&) + 453
9   Chromium Embedded Framework         0x000000010575b727 IPC::(anonymous namespace)::TryFiltersImpl(std::vector<IPC::MessageFilter*, std::allocator<IPC::MessageFilter*> >&, IPC::Message const&) + 119
10  Chromium Embedded Framework         0x000000010575b66f IPC::MessageFilterRouter::TryFilters(IPC::Message const&) + 143
11  Chromium Embedded Framework         0x00000001057225ba IPC::ChannelProxy::Context::TryFilters(IPC::Message const&) + 346
12  Chromium Embedded Framework         0x00000001057227e2 IPC::ChannelProxy::Context::OnMessageReceived(IPC::Message const&) + 50
13  Chromium Embedded Framework         0x000000010572e707 IPC::internal::ChannelReader::DispatchMessage(IPC::Message*) + 471
14  Chromium Embedded Framework         0x000000010572df0e IPC::internal::ChannelReader::TranslateInputData(char const*, int) + 958
15  Chromium Embedded Framework         0x000000010572dac5 IPC::internal::ChannelReader::ProcessIncomingMessages() + 389
16  Chromium Embedded Framework         0x000000010571ad38 IPC::ChannelPosix::OnFileCanReadWithoutBlocking(int) + 1608
17  Chromium Embedded Framework         0x000000010571af72 non-virtual thunk to IPC::ChannelPosix::OnFileCanReadWithoutBlocking(int) + 50
18  Chromium Embedded Framework         0x00000001006ec258 base::MessagePumpLibevent::FileDescriptorWatcher::OnFileCanReadWithoutBlocking(int, base::MessagePumpLibevent*) + 88
19  Chromium Embedded Framework         0x00000001006ed9c9 base::MessagePumpLibevent::OnLibeventNotification(int, short, void*) + 809
20  Chromium Embedded Framework         0x000000010090f7cd event_process_active + 365
21  Chromium Embedded Framework         0x000000010090ebc4 event_base_loop + 468
22  Chromium Embedded Framework         0x00000001006eddde base::MessagePumpLibevent::Run(base::MessagePump::Delegate*) + 782
23  Chromium Embedded Framework         0x000000010079a273 base::MessageLoop::RunHandler() + 275
24  Chromium Embedded Framework         0x00000001007fb5b5 base::RunLoop::Run() + 85
25  Chromium Embedded Framework         0x000000010079916d base::MessageLoop::Run() + 269
26  Chromium Embedded Framework         0x000000010086cf77 base::Thread::Run(base::MessageLoop*) + 39
27  Chromium Embedded Framework         0x00000001060cbff7 content::BrowserThreadImpl::IOThreadRun(base::MessageLoop*) + 71
28  Chromium Embedded Framework         0x00000001060cc1ee content::BrowserThreadImpl::Run(base::MessageLoop*) + 334
29  Chromium Embedded Framework         0x000000010086d310 base::Thread::ThreadMain() + 784
30  Chromium Embedded Framework         0x0000000100857bc8 base::(anonymous namespace)::ThreadFunc(void*) + 216
31  libsystem_pthread.dylib             0x00007fff8ebd805a _pthread_body + 131
32  libsystem_pthread.dylib             0x00007fff8ebd7fd7 _pthread_body + 0
33  libsystem_pthread.dylib             0x00007fff8ebd53ed thread_start + 13


I hope someone can help me fix this.

Cheers

somebody
somebodyy
Newbie
 
Posts: 7
Joined: Wed Aug 19, 2015 10:51 am

Re: Fatal crash with custom scheme

Postby amaitland » Tue Aug 25, 2015 6:36 pm

You have to implement `CefApp::OnRegisterCustomSchemes` in both your browser process (main app) and render process.

I think `cefclient` has a sample implementation of `OnRegisterCustomSchemes`
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: Fatal crash with custom scheme

Postby somebodyy » Tue Aug 25, 2015 7:27 pm

Thanks!
For anyone wondering:
In process_helper_mac.cc you will have to pass an instance of a subclass of `CefApp` as the second parameter to `CefExecuteProcess`.
This subclass should override `OnRegisterCustomSchemes` in the same way as you do in `SimpleApp`. You could e.g. create a common superclass which implements `OnRegisterCustomSchemes`.
somebodyy
Newbie
 
Posts: 7
Joined: Wed Aug 19, 2015 10:51 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 105 guests