T0neg0dGUI: Renderer Exception when showing window in Android

Hey guys, I’m starting to check out jMe in Android. I’m using @T0neg0d 's GUI and I’m trying to hide a window, and show another one.
This works great on desktop ( not a pro here, but not the first time I’ve done his either), but in my phone, I get a RendererException. It’s a Sony Xperia L, (+info)
The exception:
[java]
E/com.jme3.app.AndroidHarness(16577): SEVERE Exception thrown in Thread[GLThread 22073,5,main]
E/com.jme3.app.AndroidHarness(16577): com.jme3.renderer.RendererException: An OpenGL error has occurred: invalid operation
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.android.RendererUtil.checkGLError(RendererUtil.java:125)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.android.OGLESShaderRenderer.updateBufferData(OGLESShaderRenderer.java:1964)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.android.OGLESShaderRenderer.setVertexAttrib(OGLESShaderRenderer.java:2006)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.android.OGLESShaderRenderer.setVertexAttrib(OGLESShaderRenderer.java:2077)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.android.OGLESShaderRenderer.renderMeshDefault(OGLESShaderRenderer.java:2317)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.android.OGLESShaderRenderer.renderMesh(OGLESShaderRenderer.java:2354)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.material.Material.render(Material.java:1119)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:523)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:322)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:371)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:788)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:719)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:983)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.renderer.RenderManager.render(RenderManager.java:1035)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.app.SimpleApplication.update(SimpleApplication.java:252)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.app.AndroidHarness.update(AndroidHarness.java:467)
E/com.jme3.app.AndroidHarness(16577): at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:349)
E/com.jme3.app.AndroidHarness(16577): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
E/com.jme3.app.AndroidHarness(16577): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
[/java]
This is exactly what I’m doing:
The screen is created like this (inside an AppState):
[java]
screen = new Screen(app, “Interface/Tonegod/Style/style_map.gui.xml”);
screen.setUseTextureAtlas(true, “tonegod/gui/style/atlasdef/atlas.png”);
screen.setUseMultiTouch(true);
screen.parseLayout(“Interface/Tonegod/lobby.gui.xml”, this);
[/java]
The stylemap I’m using just points to the original style in the library, but with a different Font file (for now).
And I’ve a Window, let’s call it WindowA in the screen wich has a Button as child, wich should hide WindowA and show WindowB.
I am hiding and showing the windows with hide() and show(), but I’ve also tryied using hideWindow() and showWindow(), and hideWithEffect() and showWithEffect().
This exception is thrown when WindowB is show, couse, I’ve commented out that line and WindowA hides fine (with the three hide methods).
So, as I’ve said, in Desktop is working fine, is there something that I’m missing for Android or is it a problem with my phone?
Thanks in advance!

Ooooh… Hey… I have not tested the layout parser on Android yet. Thanks for reminding me. It is likely the actual parser and Android atm. It may not be adding the effects properly.

EDIT: Actually, I may have missed an initial alpha setting. Are you using the standard effects? i.e. FadeIn, FadeOut?

1 Like
@t0neg0d said: Ooooh... Hey... I have not tested the layout parser on Android yet. Thanks for reminding me. It is likely the actual parser and Android atm. It may not be adding the effects properly.
Oh ok no problem mate. if it helps of anything, It works fine if I just re create the window every time, and also the hides methods works fine each of them. Btw, if you think of any temporary fix that I can use for now, let me know. thanks mate!

EDIT: the hideWithEffect() method throws the same exception.

@t0neg0d said:

EDIT: Actually, I may have missed an initial alpha setting. Are you using the standard effects? i.e. FadeIn, FadeOut?


Yeah, I haven’t added any effects, and I haven’t modified the Window file.

@turco.chaia
I am soooo sorry. When I realized this was an issue on some devices, I updated the effects to go no lower than value 0.01f, which stops the above error. I apparently missed FadeIn’s start value =(

I’m updating it now. I’ll commit it to the repo soon and it will be available with tonight’s update.

@t0neg0d said: @turco.chaia I am soooo sorry. When I realized this was an issue on some devices, I updated the effects to go no lower than value 0.01f, which stops the above error. I apparently missed FadeIn's start value =(

I’m updating it now. I’ll commit it to the repo soon and it will be available with tonight’s update.


@t0neg0d you don’t have to be sorry at all, I am aware that this is a “somewhere beteween Alpha/Beta release”. So it’s now where things like this must happen.
Glad to have helped somehow lol.
EDIT: Just to be sure, where you able to reproduce this error?

@turco.chaia said: @t0neg0d you don't have to be sorry at all, I am aware that this is a "somewhere beteween Alpha/Beta release". So it's now where things like this must happen. Glad to have helped somehow lol. EDIT: Just to be sure, where you able to reproduce this error?

I can’t personally, but your report let me know by the fact that showWithEffect was throwing the error where hideWidthEffect did not.

When I went and looked at the code, I indeed did miss the check on the initial value on FadeIn. EDIT: Meaning it was initially showing at a value of 0f which I’m 99.9% sure is the cause of the above error.

Oh… also, I commited the update to Effect.java… if you’re pulling the code from the repo, it’s available now.

1 Like
@t0neg0d said: Oh... also, I commited the update to Effect.java... if you're pulling the code from the repo, it's available now.
Sorry for the delay mate. Ive updated the lib, ( throgh the sdk plugins), and running this simple test this it's obviously fixed:

[java]
screen = new Screen(this, “tonegod/gui/style/atlasdef/style_map.gui.xml”);
screen.setUseTextureAtlas(true, “tonegod/gui/style/atlasdef/atlas.png”);
screen.setUseMultiTouch(true);
// screen.setUseKeyboardIcons(true);
guiNode.addControl(screen);
screen.setUseKeyboardIcons(true);

    windowA = new Window(screen, new Vector2f((screen.getWidth() / 2) - 175, (screen.getHeight() / 2) - 100));
    windowA.setWindowTitle("Window A");
    screen.addElement(windowA);

    Button buttonA = new ButtonAdapter(screen, new Vector2f(25, 50)) {
        @Override
        public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
            windowA.hideWithEffect();
            windowB.showWithEffect();
        }
    };
    buttonA.setText("Show B");
    windowA.addChild(buttonA);


    windowB = new Window(screen, new Vector2f((screen.getWidth() / 2) - 175, (screen.getHeight() / 2) - 100));
    windowB.setWindowTitle("Window B");
    screen.addElement(windowB);
    windowB.hide();

    Button buttonB = new ButtonAdapter(screen, new Vector2f(25, 50)) {
        @Override
        public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
            windowB.hideWithEffect();
            windowA.showWithEffect();
        }
    };
    buttonB.setText("Show A");
    windowB.addChild(buttonB);

[/java]
this works great, with any show/hide method.
But I think that this same problem is affecting other elements, couse I’m still getting the exception in my project. Obviously I don’t have just two empty windows with a button.
The show method works fine (which didn’t before the update), but when I hide the window, and show back the one wich was hidden I get the same exception.
EDIT: I get the same exception in my project, not in the example above

Both windows have ScrollArea, Label and Button inside.
I’m going to add those elements to the test I’ve just posted and check what happens.

1 Like

@t0neg0d I’ve tracked the issue to the ScrollArea. Somehow, if I add to that example a ScrollArea to WindowA by java, it works without problem.
But, If I parse an XML layout wich has a ScrollArea in WindowA, it hides, and shows WindowB, but I get the exception showing back WindowA. If I remove the scroll Area from WindowA in the XML it works. Maybe this can give you some idea about the problem? for now I’ll just create the layout with Java.
Thank you very much.

1 Like
@turco.chaia said: @t0neg0d I've tracked the issue to the ScrollArea. Somehow, if I add to that example a ScrollArea to WindowA by java, it works without problem. But, If I parse an XML layout wich has a ScrollArea in WindowA, it hides, and shows WindowB, but I get the exception showing back WindowA. If I remove the scroll Area from WindowA in the XML it works. Maybe this can give you some idea about the problem? for now I'll just create the layout with Java. Thank you very much.

Awesome… thanks for this. I’ll start working on testing/fixing the layout parser with android over the weekend!

1 Like

Btw, the update won’t post until tonight, so the plugin still has the Effect error in it.

1 Like
@t0neg0d said: Awesome... thanks for this. I'll start working on testing/fixing the layout parser with android over the weekend!
No problem, if this helps you I'm glad I've done it. I'll let you know if I find out more about this.
@t0neg0d said: Btw, the update won't post until tonight, so the plugin still has the Effect error in it.
Yah, I thought that after reading again what you said about it being in the repo, but I saw an update from the IDE about your lib from today (23 March) as soon as I read that so I thought it was that lol. Maybe it's been the ScrollArea the whole time? EDIT: couse if I remove the scrollArea from the XML layout in my proyect everything works great.. EDIT2: And If I instead add the ScrollArea from java (and remove it from the XML) it also works great.

The issue is with the isTextOnly “thing”. I mean. If I add the ScrollArea from Java, and in the constructor I set isTextOnly to true

[java]
ScrollArea scrollArea = new ScrollArea(screen, Vector2f.ZERO, true);
windowA.addChild(scrollArea);
[/java]

I get the exception. I imagine that If I create the ScrollArea from XML, isTextOnly is defined as TRUE, and that’s why it crashes.
But, If I define isTextOnly as false in Java:

[java]
ScrollArea scrollArea = new ScrollArea(screen, Vector2f.ZERO, false);
windowA.addChild(scrollArea);
[/java]
everything works fine.
So that should point you in the right way! have fun this weekend!
EDIT: To be clear, the ScrollArea was empty. Had no Element inside.

By the way, the ScrollArea class doesn’t have a setIsTextOnly method, to modify the status of isTextOnly after the object has been created. Probably this is intentional. But just in case.

@turco.chaia said: By the way, the ScrollArea class doesn't have a setIsTextOnly method, to modify the status of isTextOnly after the object has been created. Probably this is intentional. But just in case.

It looks like you define this in the constructor. I had to check… couldn’t remember >.<

EDIT: I think it configures in child elements differently depending on this flag

@t0neg0d said: It looks like you define this in the constructor. I had to check.. couldn't remember >.<

EDIT: I think it configures in child elements differently depending on this flag


Yeah you define it in the constructor, but It cant be modified afterwards.
It all comes down to the isTextOnly feature.
If that’s enabled, I get the Renderer exception when hiding the window. If it isn’t enabled, it works fine.

@turco.chaia said: Yeah you define it in the constructor, but It cant be modified afterwards. It all comes down to the isTextOnly feature. If that's enabled, I get the Renderer exception when hiding the window. If it isn't enabled, it works fine.

Interesting. Ok… I’ll try and figure out why this is.

Try the AlertBox or DialogBox and see if this happens as well. I believe they are configured this way and will help narrow down the issue. Um… that is… if you’re still using the xml parser. If so, it could be an issue with how this is building out the ScrollArea, otherwise… I’ll be able to track it down within the ScrollArea class.

I think that if you create a ScrollArea with the XML parser, by default isTextOnly is true. That’s why it crashed when I used XML.
Take a look at this code:

[java]
screen = new Screen(this, “tonegod/gui/style/atlasdef/style_map.gui.xml”);
screen.setUseTextureAtlas(true, “tonegod/gui/style/atlasdef/atlas.png”);
screen.setUseMultiTouch(true);
// screen.setUseKeyboardIcons(true);
guiNode.addControl(screen);
screen.setUseKeyboardIcons(true);

    windowA = new Window(screen, new Vector2f((screen.getWidth() / 2) - 175, (screen.getHeight() / 2) - 100));
    windowA.setWindowTitle("Window A");
    screen.addElement(windowA);

// ScrollArea scrollArea = new ScrollArea(screen, new Vector2f(25, 80), true);
ScrollArea scrollArea = new ScrollArea(screen, new Vector2f(25, 80), false);

    windowA.addChild(scrollArea);

    Button buttonA = new ButtonAdapter(screen, new Vector2f(25, 50)) {
        @Override
        public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
            windowA.hideWithEffect();
            windowB.showWithEffect();
        }
    };
    buttonA.setText("Show B");
    windowA.addChild(buttonA);


    windowB = new Window(screen, new Vector2f((screen.getWidth() / 2) - 175, (screen.getHeight() / 2) - 100));
    windowB.setWindowTitle("Window B");
    screen.addElement(windowB);
    windowB.hide();

    Button buttonB = new ButtonAdapter(screen, new Vector2f(25, 50)) {
        @Override
        public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
            windowB.hideWithEffect();
            windowA.showWithEffect();
        }
    };
    buttonB.setText("Show A");
    windowB.addChild(buttonB);

[/java]
It works fine as it is, but if you set isTextOnly to true, it crashes when switching windows. I think It has to do with the VScrollBar (just a guess tho), couse if isTextOnly is false, I belive it doesnt show right (the VScrollBar)? but if it’s true, it does, and thats when I get the exception.
So I don’t think it has nothing to do with the XML parser. It was just coincidence.
All of this is in Android, in desktop it’s all fine (just in case).