Fatal error when rendering text

First of all, JOGL is great.
Second, I’m glad JOGL is now capable of rendering text!

However, I’m experiencing serious errors while rendering text. My application draws labels on a
dragable canvas. Depending on which labels are currently visible in the viewport, some labels
are drawn correct, some are shown as black rectangles, and some others are simply not visible
(see screen shot). Occasionally, the application even crashes (see below and attached error log).
`

An unexpected error has been detected by Java Runtime Environment:

EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x690f6f9d, pid=3056, tid=2144

Java VM: Java HotSpot™ Client VM (1.6.0-b105 mixed mode, sharing)

Problematic frame:

C [atioglxx.dll+0xf6f9d]

An error report file with more information is saved as hs_err_pid3056.log

`

I’m using JDK6, JOGL 1.1 rc3, WindowsXP, ATI Radeon 9600 Pro (latest drivers). The rendering
code is basically as follows:


// *** code from somewhere in the display method ***

gl.glDisable(GL.GL_DEPTH_TEST);
gl.glDisable(GL.GL_LIGHTING);

TextRenderer textPlain = new TextRenderer(plainFont, true, true);
textPlain.beginRendering(glDrawable.getWidth(), glDrawable.getHeight());

TextRenderer textLarge = new TextRenderer(largeFont, true, true);
textLarge.beginRendering(glDrawable.getWidth(), glDrawable.getHeight());

// Iterate over all nodes
for (Node labelNode : nodeList.keySet()) {
  //*
  // some code to compute label positions
  // 
  // Draw either plain or large label
  if (drawPlainLabel) {
	textPlain.setColor(0.3f, 0.3f, 0.3f, 1f);
	textPlain.draw(labelNode.getLabel(), (int) x, (int) (glDrawable.getHeight() - y));
  }
  else {
	textLarge.setColor(0, 0, 0, 1);
	textLarge.draw(labelNode.getLabel(), (int) x, (int) (glDrawable.getHeight() - y));
  }
textPlain.endRendering();
textPlain.dispose();
textLarge.endRendering();
textLarge.dispose();
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); // Restore blend function

Any help regarding this issue is very much appreciated. Thanks in advance!!!

What kind of ATI graphics card do you have? Are you running the latest drivers from ATI?

Did you specify -Dsun.java2d.noddraw=true on the command line? If not, does specifying it change anything?

Do the standard JOGL text demos work? Have you tried installing a DebugGL in your GLEventListener.init() to see if any errors are reported?

Thanks for the prompt reply!

  • I use Sapphire Radeon 9600 Pro 128 MB 8xAGP with latest driver (ver. 7.1).
  • I tested with -Dsun.java2d.noddraw=true, but nothing changed.
  • All jogl text demos work impressively well.
  • I installed DebugGL and occasionally my app catches the following exception:

GraphViewPanel caused a serious exception. CGV will exit.
javax.media.opengl.GLException: glGetError() returned the following error codes after a call to glPopAttrib(): GL_INVALID_OPERATION
at javax.media.opengl.DebugGL.checkGLGetError(DebugGL.java:12715)
at javax.media.opengl.DebugGL.glPopAttrib(DebugGL.java:6762)
at com.sun.opengl.util.j2d.TextureRenderer.endRendering(TextureRenderer.java:478)
at com.sun.opengl.util.j2d.TextureRenderer.endOrthoRendering(TextureRenderer.java:409)
at com.sun.opengl.util.j2d.TextRenderer.endRendering(TextRenderer.java:588)
at com.sun.opengl.util.j2d.TextRenderer.endRendering(TextRenderer.java:487)
at cgv.visualcomponents.GraphViewPanel.display(GraphViewPanel.java:1340)
at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at javax.media.opengl.GLJPanel$Updater.display(GLJPanel.java:1005)
at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at com.sun.opengl.impl.GLPbufferImpl$DisplayAction.run(GLPbufferImpl.java:222)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
at com.sun.opengl.impl.GLPbufferImpl.maybeDoSingleThreadedWorkaround(GLPbufferImpl.java:208)
at com.sun.opengl.impl.GLPbufferImpl.display(GLPbufferImpl.java:88)
at javax.media.opengl.GLJPanel.paintComponent(GLJPanel.java:605)
at javax.swing.JComponent.paint(JComponent.java:1022)
at javax.swing.JComponent.paintChildren(JComponent.java:859)
at javax.swing.JComponent.paint(JComponent.java:1031)
at cgv.visualcomponents.GraphViewPanel.paint(GraphViewPanel.java:421)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5104)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1386)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1317)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:301)
at javax.swing.RepaintManager.paint(RepaintManager.java:1132)
at javax.swing.JComponent._paintImmediately(JComponent.java:5052)
at javax.swing.JComponent.paintImmediately(JComponent.java:4862)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:727)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:683)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:663)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Any idea ??? Thanks!

PS.: I use neither glPopAttrib nor glPushAttrib anywhere in my code!

Try taking out the JOGL text rendering but leaving in the DebugGL and see if any OpenGL errors are reported by your application. Given that the JOGL text demos work, my best guess is that something is going wrong with the OpenGL state in your app and it’s causing problems with the TextRenderer or its implementing classes.

Do you have another machine / graphics card to try running with? The Radeon 9600 is pretty old and I wouldn’t be surprised if ATI’s support for it in their drivers is less than stellar.

In my app I can switch labels on/off. When labels are off, everything is fine, no
crashes occur. I tried on other machines with ATI Mobility Radeo and
NVIDIA 7800. On those machines all labels are drawn correctly.

So what I take away is that it’s a driver issue, OR is there any possibility that
the problem could be caused by jogl internal classes?? Maybe some restrictions
of texture size, since it seems that rather long labels cause problems!

Is there a way to get more runtime information from DebugGL; maybe some details
on the error or on GL states?

Thanks again!

The TextRenderer should clamp the size of its internal backing store texture to OpenGL’s maximum width and height, though it’s possible there are other constraints like total VRAM size it isn’t paying proper attention to. If you can boil things down to a small self-contained test case I can see if I can reproduce the failure in-house on a Radeon 9800.

The DebugGL already provides all of the information it can about which OpenGL error was raised, for example. You’d need to explicitly add more code to the app or JOGL to be able to do more queries about state when an error is detected.

I prepared a minimalistic app with which I can reproduce the text problem.
If I use CTRL+ mouse wheel to adjust the font size, the label becomes a
black box at certain font sizes 18pt or so.

I attached the source to this post.

I tested the minimalistic app on a brandnew IBM Thinkpad with ATI FireGL5200 (with latest driver)
running Windows Vista. The problem can be reproduced on that system!!! Though the app didn’t
crash, it still shows a filled rectangle instead of the label if font size is increased.

So, maybe it’s not a driver issue!!!

Thanks for the test case. There was a bug in the JOGL TextRenderer where the first render after the resizing of the backing store would attempt to use a texture object which had already been deleted, which was probably the cause of the crash you saw and definitely the cause of the rendering artifacts. I’ve filed and fixed Issue 275 on this topic. The fix will be in nightly builds dated 2/22 and later; please let me know if you still see problems.

FYI, you should re-use the same TextRenderer object over and over (as long as you’re still rendering with the same font) rather than creating and disposing them each frame, or you will be creating and destroying lots of OpenGL texture objects. Also there were some coding bugs with your test case (like having nested calls to beginRendering() on two different TextRenderers) as written which I assume were just due to hacking up the test case.

I’m sorry, but the nightly build doesn’t solve the problem. I still see filled rectangles and
experience crashes in my application (see below). Now it seems the problems are also
related to resizing of the JOGL component. In my minimalistic test case, labels simply
disappear once a certain font size is reached. All these things happen despite the fact that
I corrected the bugs you’ve pointed out in my test case (e.g. no more nested calls of
beginRendering() / endRendering()).

Thanks for your help!!!

Exception in thread “AWT-EventQueue-0” javax.media.opengl.GLException: glGetError() returned the following error codes after a call to glEnable(): GL_INVALID_ENUM
at javax.media.opengl.DebugGL.checkGLGetError(DebugGL.java:12715)
at javax.media.opengl.DebugGL.glEnable(DebugGL.java:1886)
at com.sun.opengl.util.texture.Texture.enable(Texture.java:175)
at com.sun.opengl.util.j2d.TextureRenderer.beginRendering(TextureRenderer.java:508)
at com.sun.opengl.util.j2d.TextureRenderer.beginOrthoRendering(TextureRenderer.java:299)
at com.sun.opengl.util.j2d.TextRenderer.beginRendering(TextRenderer.java:565)
at com.sun.opengl.util.j2d.TextRenderer.beginRendering(TextRenderer.java:332)
at JoglLabelTest$JoglLabelTestComponent.display(JoglLabelTest.java:80)
at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at javax.media.opengl.GLJPanel$Updater.display(GLJPanel.java:1005)
at javax.media.opengl.GLJPanel$DisplayAction.run(GLJPanel.java:1162)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
at javax.media.opengl.GLJPanel.paintComponent(GLJPanel.java:607)

OR

javax.media.opengl.GLException: glGetError() returned the following error codes after a call to glTexSubImage2D(): GL_INVALID_VALUE
at javax.media.opengl.DebugGL.checkGLGetError(DebugGL.java:12715)
at javax.media.opengl.DebugGL.glTexSubImage2D(DebugGL.java:9136)
at com.sun.opengl.util.texture.Texture.updateSubImageImpl(Texture.java:827)
at com.sun.opengl.util.texture.Texture.updateSubImage(Texture.java:562)
at com.sun.opengl.util.j2d.TextureRenderer.sync(TextureRenderer.java:245)
at com.sun.opengl.util.j2d.TextRenderer.draw3D(TextRenderer.java:454)
at com.sun.opengl.util.j2d.TextRenderer.draw(TextRenderer.java:399)
at cgv.visualcomponents.GraphViewPanel.display(GraphViewPanel.java:1339)
at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78)
at javax.media.opengl.GLJPanel$Updater.display(GLJPanel.java:1005)
at javax.media.opengl.GLJPanel$DisplayAction.run(GLJPanel.java:1162)
at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194)
at javax.media.opengl.GLJPanel.paintComponent(GLJPanel.java:607)

Sorry for the trouble. First, I’m not seeing the problems with the text disappearing from your test case. I can make the text as large as the system will allow and it is always rendered. There does however appear to be a bug in the TextRenderer implementation (specifically, the RectanglePacker class) when it exceeds the maximum width supported (which is equal to the OpenGL maximum texture size, in this case), but this manifests itself as an infinite loop, not incorrect rendered output.

Can you provide another test case (or your application if necessary) which is more complex and which demonstrates the filled rectangle problem? Please open a bug with the JOGL Issue Tracker (you’ll need to be an Observer of the project) and attach any test cases to it. If you aren’t comfortable putting your app in the bug report then contact me via email; my address is on the JOGL home page next to the Project Owner text.

I didn’t see a crash log from your application; did you mean to attach one?

What’s the output from this code snippet on your system?


      int[] sz = new int[1];
      gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, sz, 0);
      System.out.println("Max texture size = " + sz[0]);

What’s the output of demos.printext.PrintExt from the jogl-demos workspace?

Ken, thank you very much for digging into this!!!

I adapted my test case to behave more similar to my app. In particular, I added code
to create a random label each frame, which I guess means more stress for the
TextRenderer. The new test case, demos.printext.PrintExt output, and some images
are attached to this post. BTW, your code snippet gives a max texture size of 2048.
And, the crashes I mentioned in my previous post are actually exceptions thrown by
DebugGL (see my previous post). If I don’t use DebugGL I see neither exceptions
nor crashes, which conforms to what you said.

Some explanations to the images:

test1.png shows the test case’s initial view. test2.png was captured after increasing
font size. Subsequently, the window was resized a bit, which resulted in solid rectangles
again (see test3.png).

App1.png shows my app after some time of zooming and panning. Notice that
labels are somehow cut off in that image (compare with app3.png). Right after app1.png
was taken I resized the window and captured app2.png. Then I increased font
size a bit and, like a miracle, labels are rendered correctly like shown in app3.png

Cgv1.png app after some time of zooming and panning (cut-off labels), cgv2.png after
increasing font size, cgv3.png after resizing the app window.

A last comment: What I find disturbing is that in the test case, even if I set quite large
font size, continuously resizing the window makes the label appear correctly, disappear,
and be drawn as solid rectangle randomly.

Ups, not much space to place attachments, so go to
http://www.informatik.uni-rostock.de/~ct/testCase.zip
to download relevant files.

Thanks!

You need to recreate the TextRenderer object in your GLEventListener.init() method. It uses an OpenGL texture internally and when you resize the GLJPanel (which will sometimes result in a pbuffer being destroyed and re-created) you need to re-create that texture. Let me know whether this addresses any more of your issues.

Thanks for your last information. I think it should be added to the TextRenderer’s documentation.
I modified my test case so that TextRenderer objects are created just before they are used. A flag
is set whenever the text renderers become invalid, so that I know when it is necessary to create
new ones. I now use 2 renderer objects in parallel: one for plain font and one for a bold italic font.
This is what I do in my application. Maybe jogl doesn’t support using two renderers in parallel??

BTW, during testing I got the exception below. It happens if I try to call dispose() on a text renderer
that has been created, but has never rendered any text.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at com.sun.opengl.util.j2d.TextRenderer$Manager.deleteBackingStore(TextRenderer.java:701) at com.sun.opengl.impl.packrect.RectanglePacker.dispose(RectanglePacker.java:290) at com.sun.opengl.util.j2d.TextRenderer.dispose(TextRenderer.java:499) at JoglLabelTest$JoglLabelTestComponent.display(JoglLabelTest.java:104) at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78) at javax.media.opengl.GLJPanel$Updater.display(GLJPanel.java:1005) at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78) at com.sun.opengl.impl.GLPbufferImpl$DisplayAction.run(GLPbufferImpl.java:222) at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194) at com.sun.opengl.impl.GLPbufferImpl.maybeDoSingleThreadedWorkaround(GLPbufferImpl.java:208) at com.sun.opengl.impl.GLPbufferImpl.display(GLPbufferImpl.java:88) at javax.media.opengl.GLJPanel.paintComponent(GLJPanel.java:605) at javax.swing.JComponent.paint(JComponent.java:1022) at javax.swing.JComponent.paintChildren(JComponent.java:859) at javax.swing.JComponent.paint(JComponent.java:1031) at javax.swing.JComponent.paintChildren(JComponent.java:859) at javax.swing.JComponent.paint(JComponent.java:1031) at javax.swing.JComponent.paintChildren(JComponent.java:859) at javax.swing.JComponent.paint(JComponent.java:1031) at javax.swing.JLayeredPane.paint(JLayeredPane.java:564) ....

I forgot to attach the PrintExt output to my previous post. Here we go:

GL vendor: ATI Technologies Inc. GL version: 2.0.6287 WinXP Release GL renderer: RADEON 9600 x86/MMX/3DNow!/SSE GL extensions: GL_ARB_multitexture GL_EXT_texture_env_add GL_EXT_compiled_vertex_array GL_S3_s3tc GL_ARB_depth_texture GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_multisample GL_ARB_occlusion_query GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_shadow GL_ARB_shadow_ambient GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat GL_ARB_texture_rectangle GL_ARB_transpose_matrix GL_ARB_vertex_blend GL_ARB_vertex_buffer_object GL_ARB_pixel_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_ARB_draw_buffers GL_ATI_draw_buffers GL_ATI_element_array GL_ATI_envmap_bumpmap GL_ATI_fragment_shader GL_ATI_map_object_buffer GL_ATI_separate_stencil GL_ATI_texture_env_combine3 GL_ATI_texture_float GL_ATI_texture_mirror_once GL_ATI_vertex_array_object GL_ATI_vertex_attrib_array_object GL_ATI_vertex_streams GL_ATIX_texture_env_combine3 GL_ATIX_texture_env_route GL_ATIX_vertex_shader_output_point_size GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_clip_volume_hint GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_object GL_EXT_multi_draw_arrays GL_EXT_packed_pixels GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_wrap GL_EXT_texgen_reflection GL_EXT_texture3D GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture_rectangle GL_EXT_vertex_array GL_EXT_vertex_shader GL_HP_occlusion_test GL_NV_blend_square GL_NV_occlusion_query GL_NV_texgen_reflection GL_SGI_color_matrix GL_SGIS_generate_mipmap GL_SGIS_multitexture GL_SGIS_texture_border_clamp GL_SGIS_texture_edge_clamp GL_SGIS_texture_lod GL_SUN_multi_draw_arrays GL_WIN_swap_hint WGL_EXT_extensions_string WGL_EXT_swap_control

Hope that helps. Thanks again!

The problem here was that the current color of the TextRenderer was being lost when the backing store was resized. This has been fixed alone with the NPE in the RectanglePacker. Our nightly build system is down right now but you can pick up the fixes out of the CVS repository if you need them urgently. Please post if you see more problems.

Sorry for posting off-topic but I must say that Ken’s dedication to the JOGL community is nothing less than extraordinary. Keep up the good work!

Thanks.

I’ve just tried the nightly builds. My test case seemed to work, but my app didn’t.
So I played around and found that jogl seems have a problem when too many
distinct strings need to be rendered. I extended the test case to render different
strings every 100ms. I can reproduce that after a few seconds errors occur in
the test case.

Test case and two documenting screen shots from my app are attached.

Sorry, but I can’t reproduce this behavior. I’ve tried on an ATI Radeon 9800 Pro on Windows XP with the latest Catalyst drivers as well as on a couple of other machines (both Windows XP and Solaris/x86) with NVidia hardware and current drivers.

I did see some text corruption with the TextFlow demo on my manager’s Windows XP laptop with Intel Integrated Graphics, but I’m not sure whether your test case will show the same problem. I’ll see if I can run it on that machine.

I’ve looked through the TextRenderer code again to see if it was doing something like deleting a currently bound texture that drivers might not handle well, but the code looks okay to me. Since I can’t reproduce the issue, I’d like to ask you whether you can look into it more; perhaps use the -Djogl.debug.TextRenderer flag to visualize its backing store and see if / when the backing store seems to get corrupted.

Works fine here too (nightly build, Windows 2K & bog-standard card/drivers) until the deriveFont() size gets to about 70 (seems to vary: between 69-75) where the code locks up…