28/04/2009

Headless gecko browser attempt 3

I reported my trouble in the comments of the bug which first proposed a new headless renderer. I got helpful comments from both Chris Lord and Sylvain Pausch, basically if your embedded application segfaults like this:
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
Make sure you have MOZILLA_FIVE_HOME environment variable pointing to the directory containing libxul.so ($prefix/lib/xulrunner-1.9.2a1pre/) when running the sample.

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

27/04/2009

Headless gecko browser attempt 1

I want to be able to run selenium in a headless browser without xvfb. While I searched the googlenet to find someone having done the same thing, I came upon this : https://bugzilla.mozilla.org/show_bug.cgi?id=446591 Which basically proposes to add a headless renderer to gecko. sounds exactly like what I need, following various indications here and there, I finally got the monster to compile and give me a supposedly headless xulrunner. here are the steps I took for this :
hg clone http://hg.mozilla.org/incubator/offscreen
cd offscreen
hg checkout headless
wget -O mozconfig https://bug446591.bugzilla.mozilla.org/attachment.cgi?id=350162
make -f client.mk build
cd ../obj-x86_64-unknown-linux-gnu
This got me my headless enabled xulrunner. Then I started trying to make a xul application with an embedded browser which I could send to the selenium core url I have a main.xul with a window, a script and a browser. The script only contains the onload of the window and gets the arguments from the command line to load the browser to the given url
function onLoad() {
  var browser = document.getElementById("browser");
  var windows = document.getElementById("main");
  var url = window.arguments[0].QueryInterface(Components.interfaces.nsICommandLine).getArgument(0);
alert(url);
  browser.loadURI(url, null, null) 
}
Works like a charm with the standard xulrunner, but when I run it headless :
jean@xps:~/dev/embedding/offbrowse$ ../obj-x86_64-unknown-linux-gnu/dist/bin/xulrunner ./application.ini http://localhost:7080/tester/
it fails with the following error :
 JavaScript error: , line 0: uncaught exception: [Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIDOMChromeWindow.getAttention]"  nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)"  location: "JS frame :: chrome://global/content/commonDialog.js :: commonDialogOnLoad :: line 195"  data: no]
and I have no idea what it means. It's been a looong time since I have felt like I was playing with unknown forces of terrible power. I don't like the look of " chrome://global/content/commonDialog.js " sounds like it is somehow trying to read something from my "production" environment ( aka my normal firefox installation) buy I have no idea how to prevent it from doing that :( A zip with all the files can be found there

18/04/2009

Strobist info

La façon la plus interessante de présenter les infos strobistes que je connaisse : http://www.flickr.com/photos/polvero/sets/72157615873440953/ je ne suis pas le seul à le penser, son stream est passé sur le blog flickr :)

15/04/2009

We are linux

Liens rapides vers les 3 videos qui ont fait les finales de la campagne we are linux de la fondation linux. Il y a une video française ! Comme il se doit le budget de la vidéo française n'est pas à la hauteur de sa créativité mais ça reste quand même bien amusant.

What it means to be free

The Origin

Linux Pub

06/04/2009

Java Barcamp Paris 4 : Spring3

I first decided to attend the Spring3 session at javacampparis4. I was curious as to what is would bring over spring 2.5 and I wanted to discuss the missing generic DAO for hibernate forcing each project to reinvent the wheel. The main new feature of Spring 3 seems to be native REST support, even though it doesn't conform to the JAX-RS specification, which became a major discussion point. There was also some discussion around the arrival of EL in the spring3 config files allowing easier and cleaner management of instanciation time variables (basically PropertyPlaceHolder on steroids). We finally discussed the pros and cons of adding an generic DAO for hibernate and/or for other database access methods.

Java Barcamp Paris 4 : l'arrivée

J'ai participé à mon premier Javacamp Paris 4 dans les locaux de google mercredi dernier (31/03), et je dois avouer que je me suis bien amusé. J'ai débarqué dans les locaux sans trop savoir ce à quoi j'allais participer, j'ai été agréablement surpris du monde rencontré Une fois le plus gros du monde réuni, nous avons procédé à une ronde de présentation, chacun tient le stylo micro, donne son nom et ses sujets d'interet Une fois le tour de présentation terminé, on passe au choix des sujets, au début ça part doucement mais comme les premiers post-its commencent à apparaitre sur le tableau, les choses s'accélèrent, et on finit par retrouver plusieurs fois les même sujets. Au final le tableau donne ça: Et on est parti chacun pour sa salle. Pour nous faire rester jusqu'au bout des discussions, le buffet est déjà dressé :