bugGNU Octave - Bugs: bug #63748, Qt graphics toolkit cannot create...

 
 

bug #63748: Qt graphics toolkit cannot create OpenGL rendering context

Submitter:  None
Submitted:  Fri 03 Feb 2023 05:36:07 AM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Need Info Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * 8.0.90
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sun 26 Feb 2023 09:57:29 PM UTC, comment #17: 


>> I think the original purpose of the m_os_context member variable was to allow rendering to work when there was no visible graphics window.


Yes. If a figure has never been made visible, its corresponding QOpenGLWidget cannot provide a valid OpenGL and Octave creates an offscreen rendering context, namely m_os_context.

Pantxo Diribarne <pantxo>
Group Member
Mon 06 Feb 2023 06:13:11 PM UTC, comment #16: 

The logic in the GLCanvas class may be wrong now (or maybe was always wrong) but I think the original purpose of the m_os_context member variable was to allow rendering to work when there was no visible graphics window.

John W. Eaton <jwe>
Group administrator
Mon 06 Feb 2023 05:04:33 PM UTC, comment #15: 

Response to comment #14

> Do you still need to set those environment variables now that you found an `opengl32.dll` library that works for you?


If I don't set the environment variables Octave can start but the figure window is frozen.

> `m_os_context` is not a pointer. It is an object of type QOpenGLContext:


Oops! It was my mistake. m_os_context is an object and not a pointer.

> Are you saying that `GLCanvas` isn't using the `QOpenGLContext` instantiated in `m_os_context` but some other context? Would we need to "assign" `m_os_context` as a context for `GLCanvas` somehow?


If I correctly understand GLCanvas has two contexts:
  1. The context that is inherited from QOpenGLWidget.
  2. m_os_context.
Probably m_os_context is related to some old codes that didn't use QOpenGLWidget, If I correctly understand.
That part of code is guarded by a macro so a user possibly may switch to other widget types that don't have a QOpenGLContext as their members.


Anonymous
Mon 06 Feb 2023 04:10:00 PM UTC, comment #14: 

Do you still need to set those environment variables now that you found an `opengl32.dll` library that works for you?


> The main problem is that "m_os_context" is a pointer to a QOpenGLContext object that never is constructed. I cannot find any "new QOpenGLContext" expression in the GLCanvas.cc.


`m_os_context` is not a pointer. It is an object of type QOpenGLContext:
https://hg.savannah.gnu.org/hgweb/octave/file/74aa32d5fd08/libgui/graphics/GLCanvas.h#l98

  QOpenGLContext m_os_context;


IIUC, it is "always constructed" (with the default constructor). See: https://doc.qt.io/qt-6/qopenglcontext.html#QOpenGLContext

> Because GLCanvas is subclass of QOpenGLWidget and QOpenGLWidget  itself has a QOpenGLContext as its private member the OpenGL driver uses that context. However if that context for some reasons becomes invalid it appears that GLCanvas switches to m_os_context  that isn't constructed.


Are you saying that `GLCanvas` isn't using the `QOpenGLContext` instantiated in `m_os_context` but some other context? Would we need to "assign" `m_os_context` as a context for `GLCanvas` somehow?

Markus Mützel <mmuetzel>
Group administrator
Mon 06 Feb 2023 03:49:40 PM UTC, comment #13: 

After some efforts I found this web page [1] from Qt project. It is noted that the mechanism of loading OpenGL driver is changed. From the instructions I can set these environment variables to force Qt to load software renderer.

set QT_OPENGL=software
set QT_OPENGL_DLL=opengl32.dll


The other problem is the opengl32.dll that is shipped with Octave 8.0.90 that wouldn't work on Windows7 and prevents the Octave program from starting. So we need to find a working dll like the one that is suggested in comment #8 or copy it from previous Octave versions.

Now everything is OK. I attached screenshot of the imshow(1) command.

Responding to comment #12
The main problem is that "m_os_context" is a pointer to a QOpenGLContext object that never is constructed. I cannot find any "new QOpenGLContext" expression in the GLCanvas.cc. Because GLCanvas is subclass of QOpenGLWidget and QOpenGLWidget  itself has a QOpenGLContext as its private member the OpenGL driver uses that context. However if that context for some reasons becomes invalid it appears that GLCanvas switches to m_os_context  that isn't constructed.


[1] https://doc.qt.io/qt-5/windows-requirements.html


Anonymous
Mon 06 Feb 2023 07:10:34 AM UTC, comment #12: 

@Anonymous from comment #11: Afaics, the only (maybe) essential difference between Octave's implementation and your example code is that Octave doesn't call `QOpenGLContext::setFormat` before `QOpenGLContext::create`. Reading the documentation for that function, I'd understand that calling it is optional (and sensible defaults are used):
https://doc.qt.io/qt-6/qopenglcontext.html#setFormat

> When the format is not explicitly set via this function, the format returned by QSurfaceFormat::defaultFormat() will be used.


Is that correct? Do you think that (for some graphics driver vendors?) it is mandatory to explicitly set some format? Which format would that be?

Markus Mützel <mmuetzel>
Group administrator
Sun 05 Feb 2023 03:21:17 PM UTC, comment #11: 

This function is related to context management, It may need a reveiw:
libgui/graphics/GLCanvas.cc

bool
GLCanvas::begin_rendering (void)
{
  bool retval = true;

  if (! isValid ())
    {
#  if defined (HAVE_QT_OFFSCREEN)
      static bool os_ctx_ok = true;
      if (os_ctx_ok && ! m_os_context.isValid ())
        {
          // Try to initialize offscreen context
          m_os_surface.create ();
          if (! m_os_context.create ())
            {
              os_ctx_ok = false;
              return false;
            }
        }

      retval = m_os_context.makeCurrent (&m_os_surface);
#  else
      retval = false;
#  endif
    }
  else
    makeCurrent ();

  return retval;
}


I don't know much about Qt but in a tutorial [1] it is pointed out that a context should be created as:


    if (!m_context) {
        m_context = new QOpenGLContext(this);
        m_context->setFormat(requestedFormat());
        m_context->create();


Also using the static method


QOpenGLContext::currentContext()


may be useful to get the last context which called makeCurrent in the current thread, or nullptr, if no context is current.


[1] https://doc.qt.io/qt-5/qtgui-openglwindow-example.html

Anonymous
Sun 05 Feb 2023 01:31:12 PM UTC, comment #10: 


> Hmm, so newer versions of mesa don't work?


That might be the case (even if not very likely).
I'd guess that it is more likely that something threading related isn't quite right in Octave.

I was just trying to find out if using a different version of the renderer would just "happen" to have the threads execute in an order that works (as a quick-and-dirty workaround - not as a real solution). But according to comment #7, at least the versions that we previously distributed don't seem to do that.

Markus Mützel <mmuetzel>
Group administrator
Fri 03 Feb 2023 06:26:32 PM UTC, comment #9: 

Hmm, so newer versions of mesa don't work?  I guess we could also build older versions, for people to randomly try to see if they work, but at some point this all seems a bit ridiculous, at least to me.

John W. Eaton <jwe>
Group administrator
Fri 03 Feb 2023 05:31:57 PM UTC, comment #8: 

I had good luck with the driver from this guy:

https://fdossena.com/?p=mesa/index.frag

(but that was with 32-bit octave on 64-bit Windows)

Just fyi.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 03 Feb 2023 12:09:51 PM UTC, comment #7: 

I have tried different opengl32.dll including llvmpipe and older softpipe versions. The opengl32.dll from Octave 6.4 behaves the same as the current version and I can see the same OpenGL related errors when clicking on the figure . For example : "GL User Error: glEnable called without a rendering context".

In the softpipe version the figure is frozen and no error is printed when clicking on the figure but the CPU usage gains to 100% for near 1 minutes and 45 seconds.

Anonymous
Fri 03 Feb 2023 09:50:29 AM UTC, comment #6: 

Good to know. So, these errors aren't just limited to WoW64 but also occur on a "real" 32-bit system.

Maybe, mesa3d has dropped support for 32-bit Windows at some point in the past (either accidentally or on purpose)?
If you are willing to experiment, could you please try copying the opengl library (and its dependencies) from, e.g., Octave 6.4 to a newer version and check if that would be working?
That might just be "opengl32.dll" and "LLVM.dll" from the "mingw32/bin" directory. (But it might require more libraries, or such a "Frankenstein"-Octave might not work at all.)

Markus Mützel <mmuetzel>
Group administrator
Fri 03 Feb 2023 08:45:46 AM UTC, comment #5: 

I'm using a 32bit windows. Because an old notebook I'm using have a Windows 7 32bit pre-installed.

Anonymous
Fri 03 Feb 2023 08:43:08 AM UTC, comment #4: 

Using the system OpenGL and Qt toolkit after using "imshow(1)" a frozen figure is created and by clicking on the figure the CPU ugage gains to 100% for near 40 seconds and then these warnings are printed:

octave:1> imshow(1)
octave:2> warning: opengl_renderer: Error 'invalid operation' (1282) occurred drawing 'text' object
warning: opengl_renderer: Error 'invalid operation' (1282) occurred drawing 'text' object
warning: opengl_renderer: Error 'invalid operation' (1282) occurred drawing 'text' object
warning: opengl_renderer: Error 'invalid operation' (1282) occurred drawing 'image' object
warning: opengl_renderer: Error 'invalid operation' (1282) occurred drawing 'axes' object


Now  CPU usage is near 0% but the command prompt cannot be seen and I should use Enter to make the command prompt visible.

The fltk toolkit works without any error.

Anonymous
Fri 03 Feb 2023 08:41:27 AM UTC, comment #3: 

Thank you for checking.

That confirms that we do have an issue with Intel graphics on 32-bit. Neither the hardware drivers nor the Mesa software OpenGL renderer works correctly.

Just out of interest: Is there a reason you are resorting to the 32-bit version? Is your OS 32-bit or 64-bit?

Markus Mützel <mmuetzel>
Group administrator
Fri 03 Feb 2023 08:13:17 AM UTC, comment #2: 

After renaming opengl32.dll and using "__opengl_info__" on Qt toolkit prints the following error:

octave:1> __opengl_info__
warning: __opengl_info__: can not obtain OpenGL information
warning: called from
    __opengl_info__ at line 65 column 5


On fltk toolkit this is the output of "__opengl_info__"


octave:3> graphics_toolkit fltk
octave:4> __opengl_info__
   version: 1.4.0 - Build 8.14.10.2364
    vendor: Intel
  renderer: Intel Pineview Platform
extensions:
  GL_EXT_blend_minmax
  GL_EXT_blend_subtract
  GL_EXT_blend_color
  GL_EXT_abgr
  GL_EXT_texture3D
  GL_EXT_clip_volume_hint
  GL_EXT_compiled_vertex_array
  GL_EXT_cull_vertex
  GL_SGIS_texture_edge_clamp
  GL_SGIS_generate_mipmap
  GL_EXT_draw_range_elements
  GL_SGIS_texture_lod
  GL_EXT_rescale_normal
  GL_EXT_packed_pixels
  GL_EXT_separate_specular_color
  GL_ARB_multitexture
  GL_EXT_texture_env_combine
  GL_EXT_bgra
  GL_EXT_blend_func_separate
  GL_EXT_secondary_color
  GL_EXT_fog_coord
  GL_EXT_texture_env_add
  GL_ARB_texture_cube_map
  GL_ARB_transpose_matrix
  GL_ARB_texture_env_add
  GL_IBM_texture_mirrored_repeat
  GL_EXT_multi_draw_arrays
  GL_NV_blend_square
  GL_ARB_texture_compression
  GL_3DFX_texture_compression_FXT1
  GL_EXT_texture_filter_anisotropic
  GL_ARB_texture_border_clamp
  GL_ARB_point_parameters
  GL_ARB_texture_env_combine
  GL_ARB_texture_env_dot3
  GL_ARB_texture_env_crossbar
  GL_EXT_texture_compression_s3tc
  GL_ARB_shadow
  GL_ARB_window_pos
  GL_EXT_shadow_funcs
  GL_EXT_stencil_wrap
  GL_ARB_vertex_program
  GL_ARB_fragment_program
  GL_EXT_stencil_two_side
  GL_ARB_vertex_buffer_object
  GL_EXT_texture_lod_bias
  GL_NV_texgen_reflection
  GL_ARB_depth_texture
  GL_WIN_swap_hint


Anonymous
Fri 03 Feb 2023 07:37:27 AM UTC, comment #1: 

That's more a work-around than a proper fix: Could you try with the OpenGL renderer installed on your system?
In Octave 8, you could use the "OpenGL Switcher" from the Start menu. In previous versions, you could manually rename "mingw32/bin/opengl32.dll", e.g., to "opengl32.bak".

Does that make a difference?

Markus Mützel <mmuetzel>
Group administrator
Fri 03 Feb 2023 05:36:07 AM UTC, original submission:  

On a 32 bit Windows starting from Octave 7 the "figure" command creates a frozen windows but it can be closed and Octave continues to work.
When using the plot command the figure again is frozen but when I click on the figure the CPU usage gains to 100% and it appears that Octave enters an endless loop.
I started octave as "octave-gui --no-gui"  and set the environment variables "LIBGL_DEBUG" and "MESA_DEBUG" to capture  stdout and stderr for OpenGL related errors.
For example I created a simple plot as:

imshow(1)


After click on the figure theses errors are printed:


octave:2> GL User Error: glViewport called without a rendering context
GL User Error: glEnable called without a rendering context
GL User Error: glDepthFunc called without a rendering context
GL User Error: glSelectBuffer called without a rendering context
GL User Error: glRenderMode called without a rendering context
GL User Error: glInitNames called without a rendering context
GL User Error: glPushName called without a rendering context
GL User Error: glMatrixMode called without a rendering context
GL User Error: glLoadIdentity called without a rendering context
GL User Error: glScaled called without a rendering context
GL User Error: glMultMatrixd called without a rendering context
GL User Error: glMatrixMode called without a rendering context
GL User Error: glLoadIdentity called without a rendering context
GL User Error: glGetIntegerv called without a rendering context
GL User Error: glOrtho called without a rendering context
GL User Error: glMultMatrixd called without a rendering context
GL User Error: glMatrixMode called without a rendering context
GL User Error: glClear called without a rendering context
GL User Error: glGetDoublev called without a rendering context
GL User Error: glMatrixMode called without a rendering context
GL User Error: glLoadIdentity called without a rendering context
GL User Error: glGetIntegerv called without a rendering context
GL User Error: glTranslatef called without a rendering context
GL User Error: glScalef called without a rendering context
GL User Error: glMultMatrixd called without a rendering context
GL User Error: glMatrixMode called without a rendering context
GL User Error: glDisable called without a rendering context
GL User Error: glClipPlane called without a rendering context
GL User Error: glClipPlane called without a rendering context
GL User Error: glClipPlane called without a rendering context
GL User Error: glClipPlane called without a rendering context
GL User Error: glClipPlane called without a rendering context
GL User Error: glClipPlane called without a rendering context
GL User Error: glGetIntegerv called without a rendering context
GL User Error: glDisable called without a rendering context
GL User Error: glDisable called without a rendering context
GL User Error: glDisable called without a rendering context
GL User Error: glDisable called without a rendering context
GL User Error: glDisable called without a rendering context
GL User Error: glDisable called without a rendering context
GL User Error: glDisable called without a rendering context
...
...
...


And the error "GL User Error: glDisable called without a rendering context" is printed in an endless loop.

The fltk  toolkit works without any problem. When using the fltk toolkit I can use _opengl_info_ and it shows that the llvmpipe is currently used. But on Qt graphics toolkit the _opengl_info_ doesn't work and an error is printed.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #54321:  scrn.png added by None (10KiB - image/png - screenshot of imshow(1))

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-02-06 None Attached File- Added scrn.png, #54321
    2023-02-03 mmuetzel StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code