I have an image that I would like to rasterize using Batik. This same image is also created to be directly viewed in Firefox. Unfortunately there's a bug in Firefox and getBBox() can't be called from within the onload handler. One has to call to a new function from within a setTimeout().
When I attempt to rasterize something in batik that includes a setTimeout using the -onload command argument, the rasterizer crashes with: TypeError: Cannot convert null to an object. For example, the image at: http://odin.himinbi.org/tests/test_batik_onload.svg java -jar batik-rasterizer.jar -h 100 -w 100 -onload test_batik_onload.svg To avoid the setTimeout in batik, I am currently using the test: if(typeof(navigator) != "undefined" && navigator.appCodeName == "Mozilla") Is there a way to directly test for whatever it is that is failing? My actual stack trace is: Converting test_batik_onload.svg to test_batik_onload.png ... org.mozilla.javascript.EcmaError: TypeError: Cannot convert null to an object. (Inline <script> file:/home/will/sites/himinbi.org/odin/tests/test_batik_onload.svg:-1#2) at org.mozilla.javascript.ScriptRuntime.constructError(Unknown Source) at org.mozilla.javascript.ScriptRuntime.constructError(Unknown Source) at org.mozilla.javascript.ScriptRuntime.typeError(Unknown Source) at org.mozilla.javascript.ScriptRuntime.typeError0(Unknown Source) at org.mozilla.javascript.ScriptRuntime.toObject(Unknown Source) at org.mozilla.javascript.ScriptRuntime.toObject(Unknown Source) at org.mozilla.javascript.Context.toObject(Unknown Source) at org.apache.batik.script.rhino.WindowWrapper.setTimeout( WindowWrapper.java:125) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke( NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke( DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.mozilla.javascript.MemberBox.invoke(Unknown Source) at org.mozilla.javascript.FunctionObject.call(Unknown Source) at org.mozilla.javascript.optimizer.OptRuntime.callName(Unknown Source) at org.mozilla.javascript.gen.c2._c1(Inline <script> file:/home/will/sites/himinbi.org/odin/tests/test_batik_onload.svg:-1:2) at org.mozilla.javascript.gen.c2.call(Inline <script> file:/home/will/sites/himinbi.org/odin/tests/test_batik_onload.svg:-1) at org.mozilla.javascript.optimizer.OptRuntime.callName0(Unknown Source) at org.mozilla.javascript.gen.c3._c0(Event attribute file:/home/will/sites/himinbi.org/odin/tests/test_batik_onload.svg:-1 onload:1) at org.mozilla.javascript.gen.c3.call(Event attribute file:/home/will/sites/himinbi.org/odin/tests/test_batik_onload.svg:-1 onload) at org.mozilla.javascript.ContextFactory.doTopCall(Unknown Source) at org.mozilla.javascript.ScriptRuntime.doTopCall(Unknown Source) at org.mozilla.javascript.gen.c3.call(Event attribute file:/home/will/sites/himinbi.org/odin/tests/test_batik_onload.svg:-1 onload) at org.mozilla.javascript.gen.c3.exec(Event attribute file:/home/will/sites/himinbi.org/odin/tests/test_batik_onload.svg:-1 onload) at org.mozilla.javascript.Context.evaluateReader(Unknown Source) at org.apache.batik.script.rhino.RhinoInterpreter$2.run( RhinoInterpreter.java:261) at org.mozilla.javascript.Context.call(Unknown Source) at org.mozilla.javascript.ContextFactory.call(Unknown Source) at org.apache.batik.script.rhino.RhinoInterpreter.evaluate( RhinoInterpreter.java:271) at org.apache.batik.bridge.BaseScriptingEnvironment$1.handleEvent( BaseScriptingEnvironment.java:624) at org.apache.batik.dom.events.EventSupport.fireEventListeners( EventSupport.java:324) at org.apache.batik.dom.events.EventSupport.fireEventListeners( EventSupport.java:366) at org.apache.batik.dom.events.EventSupport.dispatchEvent( EventSupport.java:266) at org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java :1014) at org.apache.batik.bridge.BaseScriptingEnvironment.dispatchSVGLoad( BaseScriptingEnvironment.java:634) at org.apache.batik.bridge.BaseScriptingEnvironment.dispatchSVGLoadEvent( BaseScriptingEnvironment.java:550) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode( SVGAbstractTranscoder.java:215) at org.apache.batik.transcoder.image.ImageTranscoder.transcode( ImageTranscoder.java:92) at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode( XMLAbstractTranscoder.java:142) at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode( SVGAbstractTranscoder.java:156) at org.apache.batik.apps.rasterizer.SVGConverter.transcode( SVGConverter.java:1001) at org.apache.batik.apps.rasterizer.SVGConverter.execute( SVGConverter.java:717) at org.apache.batik.apps.rasterizer.Main.execute(Main.java:938) at org.apache.batik.apps.rasterizer.Main.main(Main.java:992) ERROR: null Enclosed Exception: TypeError: Cannot convert null to an object. (Inline <script> file:/home/will/sites/himinbi.org/odin/tests/test_batik_onload.svg:-1#2) ... success
