As requested by dcrocha I post this here too.

Actually, this are two posts, which are related.

The short summary is that I can not get SVG to work on higher resolutions than 172x208. The emulator crashes at qvga or double resolution. I tried this on my local machine with java 1.5 and on a fresh vmware virtual machine wich java 1.4 (latest version of 1.4.2), with identical results. I use a german os (windows xp pro), and i do not have access to an english one.

I originally thought it is caused by setViewPort, but it isn't. It crashes when the image is of a certain size. That size is not constant, unfortunatly. I tried this out with a simple midlet that increased the viewport when a key is pressed. It then always crashed, but not always at the same size.

I tried to make the simplest midlet to reproduce this behaviour (post2). This midlet crashes always (or lets the emulator crash..).

The interesting thing is that it does not crash using the "single resolution" 176x208 - no matter what size of the image or viewport i use!

First Post:
I'm trying to develop a user interface in java based on SVG. But I have problems with the emulator - when I switch to double resolution (352x416), the emulator quits without an error message. I'm using the Prototype S60 MIDP Emulator.

It seems that it is related to setViewportWidth/setViewportHeight. If I do not call this methods, the emulator does not quit. I originally had setViewportWidth/Height in the creator function of the SVGImage, and in sizeChanged. It works only when I remove both calls to setViewportWidth.

I use the latest Nokia Prototype SDK that was included in Carbide.j.

Java -version say:
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)


Second post (relevant parts):

When I switch to 352x416 and start the applet, the paint function terminates the emulator completly. I either get no message at all or a window error message "An error was encountered - program exited abnormally" (sorry, I use german OS, I do not know the exact message in english).

I made a simple midlet, a very simple svg file and made jad/jar using CLDC1.1 and MIDP2.0.

SVG File: (svg1.svg)
<svg width="300" height="280" stroke="none">
<rect fill="#f00" x="0" y="0" width="300" height="280"/>
</svg>

Javafile (svgmidlet.java):
/* This file was created by Carbide.j */

package svgtest;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.game.*;
import javax.microedition.lcdui.*;
import javax.microedition.m2g.*;
import java.io.*;

public class svgmidlet extends MIDlet
{
MainDisplay mDisplay;

public svgmidlet(){}

protected void startApp( ) throws MIDletStateChangeException
{
mDisplay = new MainDisplay();
Display.getDisplay(this).setCurrent(mDisplay);
}

protected void pauseApp( ){}

protected void destroyApp( boolean p1 ) throws MIDletStateChangeException
{mDisplay = null;}

class MainDisplay extends GameCanvas
{
private Graphics mBuffer = null;
private ScalableGraphics mRenderer;
private SVGImage mImage;

MainDisplay() {
super(false);
LoadImage();
}

private void LoadImage()
{
try {
InputStream tStream = getClass().getResourceAsStream("svg1.svg");
mImage = (SVGImage)SVGImage.createImage(tStream, null);
} catch(Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
protected void showNotify()
{
DrawBuffer();
System.out.println("show");
super.showNotify();
}
void DrawBuffer()
{
if(mBuffer==null) mBuffer = getGraphics();
if(mRenderer==null) mRenderer = ScalableGraphics.createInstance();

mBuffer.setColor(0,0,255);
mBuffer.fillRect(0,0,getWidth(), getHeight());
mBuffer.setColor(0,0,0);
mBuffer.drawString("Hello", 0,0,0);

mRenderer.bindTarget(mBuffer);
mRenderer.render(0,0,mImage);
mRenderer.releaseTarget();
}
}
}