28/04/2009

Headless gecko browser attempt 2

Okay since my attempt at using xulrunner failed, I tried again with c compilation. I went back in shame to my make manual and relearned the make basics. Using error and trial I finally got chris lord's example to compile, but it fails on a segfault. Now I remember why I dislike C so much :( For further reference, here is my makefile :
GLIB_CFLAGS = -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include \
 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/local/include
CFLAGS = -I./include/ -I../include/mozheadless/ -I../include/cairo/
LIBDIRS += ./lib/ ../lib/ /usr/lib/ /lib/ ../bin/
LDFLAGS= -L./lib -L ../lib -L../bin
LDLIBS= -lcairo -lglib-2.0 -lxul -lsqlite3 -lmozjs -lsoftokn3 -lnssutil3 -lnss3 -lnspr4

all: offbrowse

clean:
 -rm printenv *~ *.o *.bak core tags shar

offbrowse: moz-headless-screenshot.c
 $(CC) $(GLIB_CFLAGS)  $(CFLAGS) $? $(LDFLAGS) $(LDLIBS) -o $@
Once compiled I copied it to the bin directory of the sdk, added the current directory to de LD_LIBRARY_PATH and tried to run it here is what I got :
./offbrowse http://www.google.com 800 600 test.png
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/jean/dev/embedding/offscreen/xpcom/base/nsTraceRefcntImpl.cpp, line 1035
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/jean/dev/embedding/offscreen/xpcom/base/nsTraceRefcntImpl.cpp, line 915
WARNING: NS_ENSURE_TRUE(compMgr) failed: file nsComponentManagerUtils.cpp, line 165
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/jean/dev/embedding/offscreen/xpcom/base/nsTraceRefcntImpl.cpp, line 915
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/jean/dev/embedding/offscreen/xpcom/base/nsTraceRefcntImpl.cpp, line 915
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/jean/dev/embedding/offscreen/xpcom/base/nsTraceRefcntImpl.cpp, line 915
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/jean/dev/embedding/offscreen/xpcom/base/nsTraceRefcntImpl.cpp, line 915
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/jean/dev/embedding/offscreen/xpcom/base/nsTraceRefcntImpl.cpp, line 915
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/jean/dev/embedding/offscreen/xpcom/base/nsTraceRefcntImpl.cpp, line 915
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/jean/dev/embedding/offscreen/xpcom/base/nsTraceRefcntImpl.cpp, line 972
WARNING: NS_ENSURE_TRUE(compMgr) failed: file nsComponentManagerUtils.cpp, line 90
WARNING: XPCOM objects created/destroyed from static ctor/dtor: 'gActivityTLS != BAD_TLS_INDEX && NS_PTR_TO_INT32(PR_GetThreadPrivate(gActivityTLS)) == 0', file /home/jean/dev/embedding/offscreen/xpcom/base/nsTraceRefcntImpl.cpp, line 972
WARNING: NS_ENSURE_TRUE(compMgr) failed: file nsComponentManagerUtils.cpp, line 165
###!!! ASSERTION: You can't dereference a NULL nsCOMPtr with operator->().: 'mRawPtr != 0', file ../../../../dist/include/xpcom/nsCOMPtr.h, line 796
Segmentation fault
all the files (Make file, moz_headless_screenshot.c and error.txt) are available here

2 commentaires:

woronosh a dit…
Ce commentaire a été supprimé par un administrateur du blog.
xogetill a dit…
Ce commentaire a été supprimé par un administrateur du blog.