Crashes when changing certain graphics options

I have recently noticed this issue in my jME3 application: when changing antialiasing and attempting to restart the display to apply the new settings, the program crashes. I am not sure whether the antialiasing change alone is the issue, it is simply how I experienced this issue for the first time.



I was able to duplicate the problem with the TestContextRestart demo by adding one line of code. Add the following after settings.setFullscreen(true):



[java]settings.setSamples(4);[/java]



The application crashes with the following error:


Jul 18, 2011 6:24:23 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
java.lang.IllegalStateException: The Drawable has no context available.
at org.lwjgl.opengl.AbstractDrawable.checkDestroyed(AbstractDrawable.java:86)
at org.lwjgl.opengl.AbstractDrawable.releaseContext(AbstractDrawable.java:50)
at org.lwjgl.opengl.Display.releaseContext(Display.java:718)
at com.jme3.system.lwjgl.LwjglDisplay.createContext(LwjglDisplay.java:130)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:177)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:218)
at java.lang.Thread.run(Thread.java:662)


I have no idea what it means, but I know someone will be able to shed some light on this issue. Thanks.
1 Like

Thanks, Fixed in SVN.

Hi, when I try to change antialiasing during runtime and restart the display, the screen turns black and nothing else happens.



For example, using HelloLoop demo, if I change antialiasing after 3 seconds, the blue cube is not visible anymore:



[java]package jme3test.helloworld;



import com.jme3.app.SimpleApplication;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;

import com.jme3.system.AppSettings;



/** Sample 4 - how to trigger repeating actions from the main event loop.

  • In this example, we make the player character rotate. /

    public class HelloLoop extends SimpleApplication {



    public static void main(String[] args) throws InterruptedException{

    AppSettings settings = new AppSettings(true);

    HelloLoop app = new HelloLoop();

    app.setSettings(settings);

    app.start();



    Thread.sleep(3000);



    settings.setSamples(4);

    app.setSettings(settings);

    app.restart();

    }



    protected Geometry player;



    @Override

    public void simpleInitApp() {

    /
    * this blue box is our player character /

    Box b = new Box(Vector3f.ZERO, 1, 1, 1);

    player = new Geometry("blue cube", b);

    Material mat = new Material(assetManager,

    "Common/MatDefs/Misc/Unshaded.j3md");

    mat.setColor("Color", ColorRGBA.Blue);

    player.setMaterial(mat);

    rootNode.attachChild(player);

    }



    /
    Use the main event loop to trigger repeating actions. /

    @Override

    public void simpleUpdate(float tpf) {

    // make the player rotate:

    player.rotate(0, 2
    tpf, 0);

    }

    }[/java]

Sorry, the question was: is someone else getting problems with changing antialiasing during runtime.

Sometimes instead of the black screen problem, the application closes with a java fatal error and generates an error log, why is this?

thanks


#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x69a6e097, pid=2248, tid=6860
#
# JRE version: 6.0_24-b07
# Java VM: Java HotSpot(TM) Client VM (19.1-b02 mixed mode, sharing windows-x86 )
# Problematic frame:
# C [atioglxx.dll+0xa3e097]
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

T H R E A D

Current thread (0x0945bc00): JavaThread "LWJGL Renderer Thread" [_thread_in_native, id=4672, stack(0x09840000,0x09890000)]

siginfo: ExceptionCode=0xc0000005, reading address 0xe568771c

Registers:
EAX=0x72656461, EBX=0x68735f42, ECX=0x395a1dc6, EDX=0x0949901b
ESP=0x0988f4fc, EBP=0xfb00000a, ESI=0x00000000, EDI=0xe5687718
EIP=0x69a6e097, EFLAGS=0x00010287

Register to memory mapping:

EAX=0x72656461
0x72656461 is pointing to unknown location

EBX=0x68735f42
0x68735f42 is pointing to unknown location

ECX=0x395a1dc6
0x395a1dc6 is pointing to unknown location

EDX=0x0949901b
0x0949901b is pointing to unknown location

ESP=0x0988f4fc
0x0988f4fc is pointing into the stack for thread: 0x0945bc00
"LWJGL Renderer Thread" prio=6 tid=0x0945bc00 nid=0x1240 runnable [0x0988f000]
java.lang.Thread.State: RUNNABLE

EBP=0xfb00000a
0xfb00000a is pointing to unknown location

ESI=0x00000000
0x00000000 is pointing to unknown location

EDI=0xe5687718
0xe5687718 is pointing to unknown location


Top of Stack: (sp=0x0988f4fc)
0x0988f4fc: 0a7b0ce0 0a19d158 0988f534 00000001
0x0988f50c: 72656461 69a5c655 09499000 0a421098
0x0988f51c: 6da2277f 0a19d158 0a421098 0a19d158
0x0988f52c: 0a19d158 0945bd18 0a1ec6e8 69a46d6a
0x0988f53c: 09499000 0988f56c 0945bc00 344133d8
0x0988f54c: 69397071 00000001 09499000 0988f56c
0x0988f55c: 0988f5c4 344133d8 696abaf7 0a1ec6e8
0x0988f56c: ffffffff 09b9b8a2 00000001 09499000

Instructions: (pc=0x69a6e097)
0x69a6e087: 24 10 73 4a 8b b6 0c 01 00 00 8d 0c 49 8d 3c 8e
0x69a6e097: 39 6f 04 75 2f 8b 4c 24 18 8b 07 8a 10 3a 11 75


Stack: [0x09840000,0x09890000], sp=0x0988f4fc, free space=317k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [atioglxx.dll+0xa3e097]

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.lwjgl.opengl.GL20.nglGetUniformLocation(ILjava/nio/ByteBuffer;IJ)I+0
j org.lwjgl.opengl.GL20.glGetUniformLocation(ILjava/nio/ByteBuffer;)I+29
j com.jme3.renderer.lwjgl.LwjglRenderer.updateUniformLocation(Lcom/jme3/shader/Shader;Lcom/jme3/shader/Uniform;)V+36
J com.jme3.renderer.lwjgl.LwjglRenderer.updateUniform(Lcom/jme3/shader/Shader;Lcom/jme3/shader/Uniform;)V
J com.jme3.renderer.lwjgl.LwjglRenderer.updateShaderUniforms(Lcom/jme3/shader/Shader;)V
J com.jme3.renderer.lwjgl.LwjglRenderer.setShader(Lcom/jme3/shader/Shader;)V
J com.jme3.material.Material.render(Lcom/jme3/scene/Geometry;Lcom/jme3/renderer/RenderManager;)V
J com.jme3.renderer.RenderManager.renderGeometry(Lcom/jme3/scene/Geometry;)V
J com.jme3.renderer.queue.RenderQueue.renderGeometryList(Lcom/jme3/renderer/queue/GeometryList;Lcom/jme3/renderer/RenderManager;Lcom/jme3/renderer/Camera;Z)V
J com.jme3.renderer.queue.RenderQueue.renderQueue(Lcom/jme3/renderer/queue/RenderQueue$Bucket;Lcom/jme3/renderer/RenderManager;Lcom/jme3/renderer/Camera;Z)V
J com.jme3.renderer.RenderManager.renderViewPortQueues(Lcom/jme3/renderer/ViewPort;Z)V
J com.jme3.renderer.RenderManager.renderViewPort(Lcom/jme3/renderer/ViewPort;F)V
J com.jme3.renderer.RenderManager.render(F)V
J com.jme3.app.SimpleApplication.update()V
J com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop()V
J com.jme3.system.lwjgl.LwjglDisplay.runLoop()V
j com.jme3.system.lwjgl.LwjglAbstractDisplay.run()V+117
j java.lang.Thread.run()V+11
v ~StubRoutines::call_stub

P R O C E S S

Java Threads: ( => current thread )
0x003e9c00 JavaThread "DestroyJavaVM" [_thread_blocked, id=3656, stack(0x00370000,0x003c0000)]
0x09446800 JavaThread "jME3 Audio Thread" daemon [_thread_blocked, id=6088, stack(0x09e50000,0x09ea0000)]
=>0x0945bc00 JavaThread "LWJGL Renderer Thread" [_thread_in_native, id=4672, stack(0x09840000,0x09890000)]
0x04178800 JavaThread "TimerQueue" daemon [_thread_blocked, id=2636, stack(0x07270000,0x072c0000)]
0x04174000 JavaThread "D3D Screen Updater" daemon [_thread_blocked, id=740, stack(0x071d0000,0x07220000)]
0x0406fc00 JavaThread "Image Fetcher 0" daemon [_thread_blocked, id=5876, stack(0x070d0000,0x07120000)]
0x04005400 JavaThread "AWT-Windows" daemon [_thread_in_native, id=2248, stack(0x04420000,0x04470000)]
0x03ffec00 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=6200, stack(0x04380000,0x043d0000)]
0x01b4d400 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=5072, stack(0x03ee0000,0x03f30000)]
0x01b48800 JavaThread "CompilerThread0" daemon [_thread_blocked, id=5120, stack(0x03e90000,0x03ee0000)]
0x01b47800 JavaThread "Attach Listener" daemon [_thread_blocked, id=1872, stack(0x03e40000,0x03e90000)]
0x01b44800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=4604, stack(0x03df0000,0x03e40000)]
0x01b3b800 JavaThread "Finalizer" daemon [_thread_blocked, id=3416, stack(0x03da0000,0x03df0000)]
0x01b39c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=1276, stack(0x03d50000,0x03da0000)]

Other Threads:
0x01afe000 VMThread [stack: 0x03d00000,0x03d50000] [id=3624]
0x01b67000 WatcherThread [stack: 0x03f30000,0x03f80000] [id=4752]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
def new generation total 4928K, used 2996K [0x24050000, 0x245a0000, 0x295a0000)
eden space 4416K, 60% used [0x24050000, 0x242ee4d0, 0x244a0000)
from space 512K, 61% used [0x24520000, 0x2456ec70, 0x245a0000)
to space 512K, 0% used [0x244a0000, 0x244a0000, 0x24520000)
tenured generation total 10944K, used 1850K [0x295a0000, 0x2a050000, 0x34050000)
the space 10944K, 16% used [0x295a0000, 0x2976eaf8, 0x2976ec00, 0x2a050000)
compacting perm gen total 12288K, used 3954K [0x34050000, 0x34c50000, 0x38050000)
the space 12288K, 32% used [0x34050000, 0x3442cb10, 0x3442cc00, 0x34c50000)
ro space 10240K, 54% used [0x38050000, 0x385cd9f8, 0x385cda00, 0x38a50000)
rw space 12288K, 55% used [0x38a50000, 0x390f13f8, 0x390f1400, 0x39650000)

To make this even more complex, I sometimes get a completely new error when changing graphics options with nifty.

[java]SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

com.jme3.renderer.RendererException: Shader link failure, shader:Shader[language=GLSL100, numSources=2, numUniforms=7, shaderSources=[ShaderSource[name=Common/MatDefs/Nifty/Nifty.vert, defines, type=Vertex], ShaderSource[name=Common/MatDefs/Nifty/Nifty.frag, defines, type=Fragment]]] info:Link info


No shader objects attached.
at com.jme3.renderer.lwjgl.LwjglRenderer.updateShaderData(LwjglRenderer.java:1108)
at com.jme3.renderer.lwjgl.LwjglRenderer.setShader(LwjglRenderer.java:1143)
at com.jme3.material.Material.render(Material.java:1023)
at com.jme3.niftygui.RenderDeviceJme.renderImage(RenderDeviceJme.java:258)
at de.lessvoid.nifty.render.image.renderstrategy.ResizeStrategy.render(ResizeStrategy.java:24)
at de.lessvoid.nifty.render.image.CompoundImageMode.render(CompoundImageMode.java:28)
at de.lessvoid.nifty.render.NiftyImage.render(NiftyImage.java:53)
at de.lessvoid.nifty.render.NiftyRenderEngineImpl.renderImage(NiftyRenderEngineImpl.java:219)
at de.lessvoid.nifty.elements.render.ImageRenderer.render(ImageRenderer.java:30)
at de.lessvoid.nifty.elements.Element.renderElement(Element.java:599)
at de.lessvoid.nifty.elements.Element.render(Element.java:577)
at de.lessvoid.nifty.screen.Screen.renderLayers(Screen.java:313)
at de.lessvoid.nifty.Nifty.render(Nifty.java:259)
at com.jme3.niftygui.NiftyJmeDisplay.postQueue(NiftyJmeDisplay.java:170)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1121)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1165)
at nyc3d.NYC3DApplication.update(NYC3DApplication.java:216)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:144)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:218)
at java.lang.Thread.run(Thread.java:662)[/java]
Here is my code for restarting the app:
[java]settings.copyFrom(desiredSettings);
restart();
nifty.resolutionChanged();[/java]
The good thing is the original error seems to be gone for now. :)

Is there a way of reproducing this by any chance?

Yes, the code of HelloLoop modified to change antialising after 3 seconds. The blue cube is not visible after that:



[java]package jme3test.helloworld;

import com.jme3.app.SimpleApplication;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;

import com.jme3.system.AppSettings;

/** Sample 4 - how to trigger repeating actions from the main event loop.

  • In this example, we make the player character rotate. /

    public class HelloLoop extends SimpleApplication {

    public static void main(String[] args) throws InterruptedException{

    AppSettings settings = new AppSettings(true);

    HelloLoop app = new HelloLoop();

    app.setSettings(settings);

    app.start();

    Thread.sleep(3000);

    settings.setSamples(4);

    app.setSettings(settings);

    app.restart();

    }

    protected Geometry player;

    @Override

    public void simpleInitApp() {

    /
    * this blue box is our player character /

    Box b = new Box(Vector3f.ZERO, 1, 1, 1);

    player = new Geometry("blue cube", b);

    Material mat = new Material(assetManager,

    "Common/MatDefs/Misc/Unshaded.j3md");

    mat.setColor("Color", ColorRGBA.Blue);

    player.setMaterial(mat);

    rootNode.attachChild(player);

    }

    /
    Use the main event loop to trigger repeating actions. /

    @Override

    public void simpleUpdate(float tpf) {

    // make the player rotate:

    player.rotate(0, 2
    tpf, 0);

    }

    }[/java]

Okay I think it should be fixed now. I was only able to reproduce the last error (No shader objects attached)

It works great! It solved my errors too!

Thanks!! :wink: