Problems with graphic on some devices

I’m facing a very strange issue with jMonkey:

I’ve created a simple app which displays something like this: http://puu.sh/5ZFFF.png. It works nicely on most smartphones I’ve tested it (Galaxy S2, Galaxy S3, Nexus 4, HTC ONE X, HTC ONE,…) However, when I put setDisplayFps(false); inside the simpleInitApp() method, it turns into this: http://puu.sh/5ZEAo.png on all listed devices except S2 and S3.

That’s very strange.
Could you post a test case?

I’ve managed to determine the problem more precisely; It’s not about the fps, it’s about empty guiNode as a result of hiding fps. The following code works perfectly well, however, as soon as I remove everything from guiNode (hide stats & fps, and remove the text), is starts bugging. The same bug appears when there are only blank nodes attached to the guiNode.

In short, the bug appears when guiNode is empty, or when there are only blank nodes on it.

[java]package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.font.BitmapText;
import com.jme3.light.DirectionalLight;
import com.jme3.light.PointLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.BatchNode;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Box;

/**

  • test

  • @author normenhansen
    */
    public class Main extends SimpleApplication {

    public static void main(String[] args) {
    Main app = new Main();
    app.start();
    }

    private Node pivot = new Node();
    private PointLight lamp_light;
    private float unit;
    public int cHeight;
    public int cWidth;

    @Override
    public void simpleInitApp() {

     cHeight = viewPort.getCamera().getHeight();
     cWidth = viewPort.getCamera().getWidth();
     if(cWidth>cHeight){
         unit = 1;
     } else {
         unit = ((float)cWidth)/((float)cHeight);
     }
     rootNode.scale(unit);
     
     viewPort.setBackgroundColor(new ColorRGBA(0.9f, 0.9f, 0.9f, 1f));
     setDisplayStatView(false);
     flyCam.setEnabled(false);
     setDisplayFps(false);
     
     guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
     BitmapText helloText = new BitmapText(guiFont, false);
     helloText.setSize(guiFont.getCharSet().getRenderedSize());
     helloText.setText(" ");
     helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);
     guiNode.attachChild(helloText);
     
     lamp_light = new PointLight();
     lamp_light.setColor(ColorRGBA.White.mult(0.5f));
     lamp_light.setRadius(12f*unit);
     lamp_light.setPosition(new Vector3f(0, 0, 6f).mult(unit));
     rootNode.addLight(lamp_light);
     DirectionalLight sun = new DirectionalLight();
     sun.setColor(ColorRGBA.White.mult(0.8f));
     sun.setDirection(new Vector3f(-.03f,-.03f,-1.1f).normalizeLocal());
     rootNode.addLight(sun);
     
     Box b = new Box(1, 1, 1);
     Geometry geom = new Geometry("Box", b);
     Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
     mat.setBoolean("UseMaterialColors",true); 
     mat.setColor("Diffuse", ColorRGBA.Blue);
     geom.setMaterial(mat);
     
     BatchNode batch = new BatchNode();
     batch.attachChild(geom);
     batch.batch();        
     pivot.attachChild(batch);
     rootNode.attachChild(pivot);
    

    }

    @Override
    public void simpleUpdate(float tpf) {
    pivot.rotate(0, tpf/3, 0);
    }

    @Override
    public void simpleRender(RenderManager rm) {
    //TODO: add render code
    }
    }
    [/java]

1 Like
@development said: I've managed to determine the problem more precisely; It's not about the fps, it's about empty guiNode as a result of hiding fps. The following code works perfectly well, however, as soon as I remove everything from guiNode (hide stats & fps, and remove the text), is starts bugging. The same bug appears when there are only blank nodes attached to the guiNode.

In short, the bug appears when guiNode is empty, or when there are only blank nodes on it.

Interesting. Have you tested to see if this happens on desktop as well? Is there an error thrown?

I recently fixed an issue where an NPE was thrown if the guiNode was empty (or maybe it was just if it had empty nodes in it) because the frustum check didn’t properly deal with null bounding boxes.
http://code.google.com/p/jmonkeyengine/source/diff?spec=svn10945&r=10924&format=side&path=/trunk/engine/src/core/com/jme3/renderer/Camera.java&old_path=/trunk/engine/src/core/com/jme3/renderer/Camera.java&old=10771

I never ported it to the 3.0.x branch though since no one had ever complained about it.

@pspeed said: Interesting. Have you tested to see if this happens on desktop as well? Is there an error thrown?

I recently fixed an issue where an NPE was thrown if the guiNode was empty (or maybe it was just if it had empty nodes in it) because the frustum check didn’t properly deal with null bounding boxes.
http://code.google.com/p/jmonkeyengine/source/diff?spec=svn10945&r=10924&format=side&path=/trunk/engine/src/core/com/jme3/renderer/Camera.java&old_path=/trunk/engine/src/core/com/jme3/renderer/Camera.java&old=10771

I never ported it to the 3.0.x branch though since no one had ever complained about it.

Wait so that was really a bug…
I had tht as well in my gui lib, and got so far around it by useing more detailed cullhints for empty nodes, but thats good to know. Was never sure if its a real bug or designed to be like this.

@Empire Phoenix said: Wait so that was really a bug... I had tht as well in my gui lib, and got so far around it by useing more detailed cullhints for empty nodes, but thats good to know. Was never sure if its a real bug or designed to be like this.

Well, the regular culling has a null check. Only the gui culling didn’t. So I made them behave the same.

Well yeah I used cullhint always for empty elements, so that this error disappears,

mind sharing your fix?

There is no error thrown, the game works normally, and when I display text on guiNode, everything is displayed normally until the text is removed, then the bug is back. It only happens on some mobile phones, on desktop it works normally.

I’ve noticed that S2 and S3 phones (devices without this bug) use android kernel 3.0.x, while other tested devices (devices with this bug) use android kernel 3.4.x, however, I have no idea how to determine if that’s the case.

just a simple hack, but what happens if you add a small transparent quad on like -z maximum in the gui node?

Might be a workaround for the moment.

I’ve solved it by adding a blank text to guiNode, but I hope someone with better jMonkey knowledge will actually find the source fo the bug :slight_smile:

Since you currently have best knowledge, might I ask you to report the bug, so it is not forgotten :slight_smile:
https://wiki.jmonkeyengine.org/legacy/doku.php/report_bugs

@development said: There is no error thrown, the game works normally, and when I display text on guiNode, everything is displayed normally until the text is removed, then the bug is back. It only happens on some mobile phones, on desktop it works normally.

I’ve noticed that S2 and S3 phones (devices without this bug) use android kernel 3.0.x, while other tested devices (devices with this bug) use android kernel 3.4.x, however, I have no idea how to determine if that’s the case.

Did you try it on desktop? Does it fail on desktop? It would be good if you could try it on desktop and tell us how it does. On desktop, does it do the same thing?

I wonder if it throws an error or does the same thing if you run it on desktop.

@Empire Phoenix said: Well yeah I used cullhint always for empty elements, so that this error disappears,

mind sharing your fix?

You mean the one I committed to source a long time ago and included the diff in my previous post?

@pspeed said: Did you try it on desktop? Does it fail on desktop? It would be good if you could try it on desktop and tell us how it does. On desktop, does it do the same thing?

I wonder if it throws an error or does the same thing if you run it on desktop.

As I said, this bug only appears on some mobile phones, on desktop everything works as it should.

@development said: As I said, this bug only appears on some mobile phones, on desktop everything works as it should.

Sorry… missed that before.

Do you develop against trunk or the stable branch? Because in the stable branch it will definitely NPE.

I’m using 3.0.4 stable, although there was no NPE reported in the application nor in the ADB log. Also, the jME HelloWorld (the floating blue cube) application doesn’t have this bug even with an empty guiNode.

@development said: I'm using 3.0.4 stable, although there was no NPE reported in the application nor in the ADB log. Also, the jME HelloWorld (the floating blue cube) application doesn't have this bug even with an empty guiNode.

If you haven’t removed the StatsAppState then there is always something in the guiNode. Calling setDisplayStatsView(false) only hides it.

Sadly I cant view http://puu.sh/5ZEAo.png, but from what is told here,

looks like I can confirm the bug with setDisplayFps(false); on my android (2.2), it turns (parts of) my screen black and generally confuses the color scheme on parts of my 3D-nodes on screen.

On desktop there is no prob at all.

It is not a problem of a empty nifty-node, but a prob of a not-empty layer.

I have no black screen as long the layer is empty with setDisplayFps(false) and setDisplayStatView(false). If I put in xml a panel inside the layer in screen, bug appears.

If I have displayed FPS my nifty code makes no probs, screen works like on desktop.

I hit that issue in my game too.
I have no clue to what it’s due, it looks like it’s a depth write issue but couldn’t manage to track the problem to the source…
I guess I’ll look more into it.

@pspeed fix is not causing the issue, I reverted back the change and still have the issue.