<div dir="ltr"><div>Hi,</div><div><br></div><div>I'm trying to write an application to open epub files with the GTK framework and webkigtk being my best option I chose to go with it.</div><div>I have to provide dual libarary support for both GTK2 and GTK3, and so I wrote thumbnailer code which uses an offscreen window to render the epub and get cairo surfaces as screenshots from it. The reason I'm including that code is because I think that might have something to do with this as because that's when the problem actually started.</div>
<div><br></div><div>Here is the crash report(segfault) code for the crash, and even though frame #27 is from my code, that is the call to GTK main, and because of that from this error report I cannot make out which part of the code is faulting, so I request you guys to please help me with this.</div>
<div><br></div><div>#0 0x00007ffff0e0851c in WTFCrash () at ../Source/WTF/wtf/Assertions.cpp:333</div><div>#1 0x00007ffff0ccd525 in JSC::evaluate (exec=exec@entry=0x7fff8810f9b0, source=..., thisValue=..., </div><div> returnedException=returnedException@entry=0x7fffffffd3a0) at ../Source/JavaScriptCore/runtime/Completion.cpp:65</div>
<div>#2 0x00007ffff51abc88 in evaluate (exception=0x7fffffffd3a0, thisValue=..., source=..., exec=0x7fff8810f9b0)</div><div> at ../Source/WebCore/bindings/js/JSMainThreadExecState.h:62</div><div>#3 WebCore::ScriptController::evaluateInWorld (this=this@entry=0x7fff7800a670, sourceCode=..., world=...)</div>
<div> at ../Source/WebCore/bindings/js/ScriptController.cpp:147</div><div>#4 0x00007ffff51abf5c in WebCore::ScriptController::evaluate (this=0x7fff7800a670, sourceCode=...)</div><div> at ../Source/WebCore/bindings/js/ScriptController.cpp:163</div>
<div>#5 0x00007ffff535c025 in WebCore::ScriptElement::executeScript (this=0x7fffe410d960, sourceCode=...) at ../Source/WebCore/dom/ScriptElement.cpp:310</div><div>#6 0x00007ffff535c2f4 in WebCore::ScriptElement::prepareScript (this=this@entry=0x7fffe410d960, scriptStartPosition=..., </div>
<div> supportLegacyTypes=supportLegacyTypes@entry=WebCore::ScriptElement::DisallowLegacyTypeInTypeAttribute)</div><div> at ../Source/WebCore/dom/ScriptElement.cpp:241</div><div>#7 0x00007ffff550670f in WebCore::HTMLScriptRunner::runScript (this=this@entry=0x7fffe415cae0, script=0x7fffe410d900, scriptStartPosition=...)</div>
<div> at ../Source/WebCore/html/parser/HTMLScriptRunner.cpp:302</div><div>#8 0x00007ffff5506f30 in WebCore::HTMLScriptRunner::execute (this=0x7fffe415cae0, scriptElement=..., scriptStartPosition=...)</div><div> at ../Source/WebCore/html/parser/HTMLScriptRunner.cpp:175</div>
<div>#9 0x00007ffff54ef853 in WebCore::HTMLDocumentParser::runScriptsForPausedTreeBuilder (this=this@entry=0x7fffe415f600)</div><div> at ../Source/WebCore/html/parser/HTMLDocumentParser.cpp:218</div><div>---Type <return> to continue, or q <return> to quit---</div>
<div>#10 0x00007ffff54ef914 in WebCore::HTMLDocumentParser::canTakeNextToken (this=this@entry=0x7fffe415f600, </div><div> mode=mode@entry=WebCore::HTMLDocumentParser::AllowYield, session=...) at ../Source/WebCore/html/parser/HTMLDocumentParser.cpp:237</div>
<div>#11 0x00007ffff54f2ce2 in WebCore::HTMLDocumentParser::pumpTokenizer (this=0x7fffe415f600, mode=WebCore::HTMLDocumentParser::AllowYield)</div><div> at ../Source/WebCore/html/parser/HTMLDocumentParser.cpp:293</div>
<div>#12 0x00007ffff54f3992 in WebCore::HTMLDocumentParser::append (this=0x7fffe415f600, inputSource=...)</div><div> at ../Source/WebCore/html/parser/HTMLDocumentParser.cpp:428</div><div>#13 0x00007ffff52e869e in WebCore::DecodedDataDocumentParser::appendBytes (this=0x7fffe415f600, writer=..., </div>
<div> data=0x7fffe4152400 "<html>\n<head>\n<title>Error</title>\n<style type=\"text/css\">\nbody {\n background-color: #fff;\n margin: 0;\n padding: 0;\n}\n\n#errorContainer {\n background: #fff;\n min-width: 35em;\n max-width: 35em;\n positio"..., length=975)</div>
<div> at ../Source/WebCore/dom/DecodedDataDocumentParser.cpp:50</div><div>#14 0x00007ffff561f594 in WebCore::DocumentLoader::commitData (this=this@entry=0x7fffe4125b00, </div><div> bytes=bytes@entry=0x7fffe4152400 "<html>\n<head>\n<title>Error</title>\n<style type=\"text/css\">\nbody {\n background-color: #fff;\n margin: 0;\n padding: 0;\n}\n\n#errorContainer {\n background: #fff;\n min-width: 35em;\n max-width: 35em;\n positio"..., length=length@entry=975)</div>
<div> at ../Source/WebCore/loader/DocumentLoader.cpp:843</div><div>#15 0x00007ffff4ff83f6 in WebKit::FrameLoaderClient::committedLoad (this=0x7fff78007230, loader=0x7fffe4125b00, </div><div> data=0x7fffe4152400 "<html>\n<head>\n<title>Error</title>\n<style type=\"text/css\">\nbody {\n background-color: #fff;\n margin: 0;\n padding: 0;\n}\n\n#errorContainer {\n background: #fff;\n min-width: 35em;\n max-width: 35em;\n positio"..., length=975)</div>
<div> at ../Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp:165</div><div>#16 0x00007ffff561e08f in WebCore::DocumentLoader::commitLoad (this=0x7fffe4125b00, </div><div> data=0x7fffe4152400 "<html>\n<head>\n<title>Error</title>\n<style type=\"text/css\">\nbody {\n background-color: #fff;\n margin: 0;\n padding: 0;\n}\n\n#errorContainer {\n background: #fff;\n min-width: 35em;\n max-width: 35em;\n positio"..., length=975)</div>
<div> at ../Source/WebCore/loader/DocumentLoader.cpp:773</div><div>#17 0x00007ffff56212b0 in WebCore::DocumentLoader::continueAfterContentPolicy (this=this@entry=0x7fffe4125b00, </div><div> policy=policy@entry=WebCore::PolicyUse) at ../Source/WebCore/loader/DocumentLoader.cpp:752</div>
<div>#18 0x00007ffff5624688 in WebCore::DocumentLoader::responseReceived (this=0x7fffe4125b00, resource=<optimized out>, response=...)</div><div> at ../Source/WebCore/loader/DocumentLoader.cpp:655</div><div>#19 0x00007ffff561d9ff in WebCore::DocumentLoader::handleSubstituteDataLoadNow (this=0x7fffe4125b00)</div>
<div> at ../Source/WebCore/loader/DocumentLoader.cpp:475</div><div>#20 0x00007ffff50fb1b1 in WebCore::ThreadTimers::sharedTimerFiredInternal (this=0x7fffe4123f50) at ../Source/WebCore/platform/ThreadTimers.cpp:132</div>
<div>#21 0x00007ffff5110b82 in WebCore::sharedTimerTimeoutCallback () at ../Source/WebCore/platform/gtk/SharedTimerGtk.cpp:49</div><div>#22 0x00007ffff3300703 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0</div><div>
#23 0x00007ffff32ffce5 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0</div><div>#24 0x00007ffff3300048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0</div><div>#25 0x00007ffff330030a in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0</div>
<div>#26 0x00007ffff46ae447 in IA__gtk_main () at /build/buildd/gtk+2.0-2.24.23/gtk/gtkmain.c:1271</div><div>#27 0x00000000004458d9 in main (argc=1, argv=0x7fffffffe1e8) at /home/rootavish/BETA/shell/main.c:324</div><div>
<br></div><div>Here is the thumbnailer code I was talking about:</div><div><br></div><div>I would really appreciate if somebody could help me with this crash, I tried asking people on the webkitgtk IRC, but didn't get help. Please I request you to point out the reason for the crash.</div>
<div><br></div><div>static cairo_surface_t* surface = NULL ;</div><div>static gboolean completed = FALSE;</div><div>static GdkPixbuf *thumbnail=NULL ;</div><div><br></div><div>static void</div><div>epub_webkit_render(EpubDocument *document,const char* uri);</div>
<div><br></div><div>//code that calls epub_webkit_render</div><div>static GdkPixbuf *</div><div>epub_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,</div><div> EvRenderContext *rc,</div>
<div> gboolean border)</div><div>{</div><div> gchar* uri = (gchar*) rc->page->backend_page;</div><div> EpubDocument *epub_document = EPUB_DOCUMENT(document);</div><div> completed = FALSE ;</div>
<div> thumbnail=NULL;</div><div> if (surface) {</div><div> cairo_surface_destroy (surface);</div><div> surface=NULL;</div><div> }</div><div> epub_webkit_render (epub_document,uri);</div><div><br>
</div><div> while (completed != TRUE ) {</div><div> /*Wait for the job to complete*/</div><div> }</div><div><br></div><div> if (thumbnail) {</div><div> return thumbnail;</div><div> }</div><div> else {</div>
<div> return NULL;</div><div> }</div><div>}</div><div><br></div><div>static void </div><div>webkit_render_cb(GtkWidget *web_view,</div><div> GParamSpec *specification,</div><div> gpointer data)</div>
<div>{</div><div> WebKitLoadStatus status = webkit_web_view_get_load_status (WEBKIT_WEB_VIEW(web_view));</div><div><br></div><div> if ( status == WEBKIT_LOAD_FINISHED )</div><div> {</div><div> surface = webkit_web_view_get_snapshot (WEBKIT_WEB_VIEW(web_view));</div>
<div> thumbnail = ev_document_misc_pixbuf_from_surface(surface);</div><div> completed=TRUE;</div><div> }</div><div>}</div><div><br></div><div>static void epub_webkit_render(EpubDocument *epub_document,const char* uri)</div>
<div>{</div><div> webkit_web_view_load_uri(WEBKIT_WEB_VIEW(epub_document->webview),uri);</div><div>}</div><div><br></div><div>static WebKitWebView*</div><div>offscreen_webview_init() </div><div>{</div><div> GtkWidget *offscreen_window = gtk_offscreen_window_new();</div>
<div> gtk_window_set_default_size(GTK_WINDOW(offscreen_window),800,600);</div><div><br></div><div> GtkWidget* scroll_view = gtk_scrolled_window_new (NULL,NULL);</div><div> gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scroll_view),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);</div>
<div> GtkWidget* web_view = webkit_web_view_new ();</div><div> WebKitWebSettings *webviewsettings = webkit_web_settings_new ();</div><div> g_object_set (G_OBJECT(webviewsettings), "enable-plugins", FALSE, NULL);</div>
<div> webkit_web_view_set_settings (WEBKIT_WEB_VIEW(web_view),webviewsettings);</div><div> g_signal_connect(WEBKIT_WEB_VIEW(web_view),"notify::load-status",G_CALLBACK(webkit_render_cb),NULL);</div><div> gtk_container_add(GTK_CONTAINER(scroll_view),web_view);</div>
<div> gtk_container_add(GTK_CONTAINER(offscreen_window),scroll_view);</div><div> gtk_widget_show_all (offscreen_window);</div><div> return WEBKIT_WEB_VIEW(web_view);</div><div>}</div><div><br></div><div>I please request you to help me with my code. I tried searching online but could not find any conclusive answers.</div>
<div><br></div><div>Regards,</div><div>Avishkar Gupta</div></div>