Skip to content

glbitmap fix for #2416 - #2446

Closed
rene-dev wants to merge 1 commit into
2.9from
glBitmapfix
Closed

rene-dev wants to merge 1 commit into
2.9from
glBitmapfix

Conversation

@rene-dev

Copy link
Copy Markdown
Member

No description provided.

@rene-dev rene-dev mentioned this pull request Apr 23, 2023
1 of 3 tasks
@rene-dev
rene-dev changed the base branch from master to 2.9 April 23, 2023 21:51
@rene-dev

Copy link
Copy Markdown
Member Author

@rene-dev

Copy link
Copy Markdown
Member Author

@allistar @dwrobel @smoe @jethornton @phillc54 @petterreinholdtsen @hansu @20after4 can you guys please test this?
I have no system that can reproduce it.

@rene-dev rene-dev changed the title fix for #2416 glbitmap fix for #2416 Apr 23, 2023
@snowgoer540

Copy link
Copy Markdown
Contributor

When @SebKuzminsky pushed commit ee2623b, that commit did cause issue on Buster (and possibly older) systems where there would be a non-transparent pixel in each character block that made the preview overlays look noisy. I tested and passed my findings to Seb and he pushed commit 710ce7e. I never saw the original issue (crash) Seb sought to fix on my Bullseye based VM.

For what it's worth, I did take the time to apply the changes in this commit to my Buster based VM and it has no issues with noisy pixels this time. So from a Buster standpoint, this change seems fine to me. But I do wonder if this will cause issue for the original group of people (whoever they were)? I guess that comes down to how similar None and ''.encode() are?

I don't have hardware that has crashes with this, so it's hard for me to test otherwise.

@ghost

ghost commented Apr 24, 2023

Copy link
Copy Markdown

It works for me on Bullseye X11 and Bookworm X11

It crashes with the following on Bookworm Wayland

File "/usr/lib/python3/dist-packages/OpenGL/error.py", line 230, in glCheckError
    raise self._errorClass(
OpenGL.error.GLError: GLError(
    err = 1285,
    description = b'out of memory',
    baseOperation = glBitmap,
    pyArgs = (0, 0, 0, 0, 0, 16.0, None),
    cArgs = (0, 0, 0, 0, 0, 16.0, None),
    cArguments = (0, 0, 0, 0, 0, 16.0, None)
)

@JayFoxRox

Copy link
Copy Markdown

I think this patch is an improvement and should be accepted.

I guess that comes down to how similar None and ''.encode() are?

The difference should be between a null pointer (~NULL) and a pointer to an empty buffer.
I couldn't find proper docs for PyOpenGL though, so there might be special cases for empty buffers.

The GL manpage specifically has a note about using NULL to advance the raster position.

It crashes with the following on Bookworm Wayland

GL_OUT_OF_MEMORY in particular is a very weird error for this situation, because the glBitmap command should barely consume any memory the way it is written now.

So this sounds like a bug with your OpenGL implementation (or a lack thereof). What implementation are you using?

If it's not a bug in the driver, then the error checking might trigger for a previous command (example, if glNewList() does not call glGetError(), so the next command which uses glGetError() sees it).

Did you try to run it through apitrace or some other OpenGL debugger?

@ghost

ghost commented Apr 24, 2023

Copy link
Copy Markdown

So this sounds like a bug with your OpenGL implementation (or a lack thereof). What implementation are you using?

The Bookworm Wayland install is just a basic up to date install with whatever dependencies that LinuxCNC requires. I still get the error on this machine if I log in to an XFCE session.

I did make a mistake though, I missed this earlier message:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/OpenGL/latebind.py", line 43, in __call__
    return self._finalCall( *args, **named )
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable

Did you try to run it through apitrace or some other OpenGL debugger?

No.

@rene-dev

Copy link
Copy Markdown
Member Author

I just ran apitrace, and the call looks correct, so None is the correct parameter.
the issue must be somewhere else.
glBitmap(width = 0, height = 0, xorig = 0, yorig = 0, xmove = 16, ymove = -25, bitmap = NULL)

@rene-dev

rene-dev commented Apr 24, 2023 •

Copy link
Copy Markdown
Member Author

@phillc54 can you upload a apitrace trace file on a non working system?
easiest way of doing it is adding apitrace trace in front of $EMCDISPLAY -ini "$INIFILE" $EMCDISPLAYARGS $EXTRA_ARGS in the linuxcnc launch script.

@ghost

ghost commented Apr 25, 2023

Copy link
Copy Markdown

I am not sure that I am doing this correctly. apitrace is v11.1+repack-1.1 installed with Synaptic.

The line now reads:
apitrace trace $EMCDISPLAY -ini "$INIFILE" $EMCDISPLAYARGS $EXTRA_ARGS

This is the result:
python3.11.trace.zip

@rene-dev

Copy link
Copy Markdown
Member Author

Can you open and run the trace file in qapitrace(apitrace-gui package), and see if it reports other errors?

@ghost

ghost commented Apr 25, 2023

Copy link
Copy Markdown

These are the results of Trace > Replay
Screen Shot 2023-04-25 at 12 39 36 pm
Screen Shot 2023-04-25 at 12 40 01 pm

@ev1313

ev1313 commented Apr 25, 2023

Copy link
Copy Markdown

Could you also provide the output of "glxinfo"?

@ghost

ghost commented Apr 25, 2023

Copy link
Copy Markdown

Sure.
glxinfo.txt

@ev1313

ev1313 commented Apr 25, 2023

Copy link
Copy Markdown

You're using the software renderer, so maybe it's an issue in the mesa software renderer?

@ghost

ghost commented Apr 25, 2023

Copy link
Copy Markdown

Would that be because all of the tests I did were on VM's? Although this machine should be identical to the one with X11.

@ev1313

ev1313 commented Apr 25, 2023

Copy link
Copy Markdown

Yes.

I don't know, if this is a bug in the mesa software render, because nobody nowadays uses these outdated functions, however it seems to be related to the following codepath in mesa:

https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/mesa/main/dlist.c#L1351
https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/mesa/state_tracker/st_cb_bitmap.c#L134
https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/mesa/main/pbo.c#L152

@ghost

ghost commented Apr 25, 2023

Copy link
Copy Markdown

If it is any help I just ran up the X11 VM which runs fine and ran glxinfo, attached is the diff between the X11 and Wayland VM's.
glxinfo.diff.txt

@ghost

ghost commented Apr 25, 2023

Copy link
Copy Markdown

OK, I made a mistake. I hadn't upgraded my X11 VM for the previous test and since upgrading it also gives the same error. I am now getting this error on four up to date Bookworm VM's, two amd64 and two arm64. Unfortunately I don't have a bare metal Bookworm to test on.

@JayFoxRox

Copy link
Copy Markdown

I don't know, if this is a bug in the mesa software render, because nobody nowadays uses these outdated functions, however it seems to be related to the following codepath in mesa:

[...]

Looks like a generic mesa bug or underspecification in OpenGL about:

  • glBitmap with NULL (which is underspecified for PBOs, and just a note in a man-page, not in the specification)
  • glBitmap being ignored based on raster-pos (which is unknown while recording a display-lists)
  • glBitmap interaction with display-lists (side-effect of modifying raster-position)

I've created an issue about mesa in https://gitlab.freedesktop.org/mesa/mesa/-/issues/8904

I think this patch is an improvement and should be accepted.

So I was wrong, due to it all being very vague in the OpenGL specification.

The mesa issue will probably affect many users for the next couple of years (until a potential fix is rolled out completly).

I now think a better solution would be to have a 0x0, 0x1/1x0 or 1x1 image with a non-zero valid buffer. It should avoid all previously mentioned issues (but you might want to read the spec again to make sure).
However, that solution (#2346) was used before and also didn't work (#2416).
Anyway, it might make sense to debug why those solutions didn't work, and attempt workarounds or fixes for those solutions.

@ev1313

ev1313 commented Apr 27, 2023

Copy link
Copy Markdown

The best solution is, to replace glBitmap in this place and instead just use normal translations to achieve the same effect.

I will build a prototype for this in the coming week.

@rene-dev

Copy link
Copy Markdown
Member Author

I implemented a workaround: fced097

@andypugh

Copy link
Copy Markdown
Collaborator

I implemented a workaround: fced097

So, should this PR be closed? And does fced097 need to be cherry-picked into 2.9?

@smoe

smoe commented Sep 15, 2023

Copy link
Copy Markdown
Collaborator

I have no idea. A later version of mesa has a fix included for glBitmap https://gitlab.freedesktop.org/mesa/mesa/-/commit/bac1c88ea3e1f0966505a3bfb016c6b2e8cbb629 but shall we wait for that? Merged three months ago, https://gitlab.freedesktop.org/mesa/mesa/-/tags suggests that 23.1.3 or later are fine. On https://tracker.debian.org/pkg/mesa it states that current testing should no longer be affected.
Since we only get backported versions of LinuxCNC into the current stable release anyway, my idea would be to have that depend on a later version of the mesa libraries, which we could then backport, too.

I do not understand what the patch is doing. I suggest leaving it in with a comment to remove it when 23.1.3 or later has become a runtime requirement.

@rene-dev

Copy link
Copy Markdown
Member Author

The patch tries the other way in case the first way fails. It's a hack, but works.

@snowgoer540

Copy link
Copy Markdown
Contributor

And does fced097 need to be cherry-picked into 2.9?

The code was the same in both 2.9 and master so it's my vote that we keep them consistent until 2.9 is released.

@gmoccapy

gmoccapy commented Oct 7, 2023

Copy link
Copy Markdown
Collaborator

stuttgart meeting says leave the workaround in until mesa is fixed upstream.

@andypugh

andypugh commented Jul 6, 2024

Copy link
Copy Markdown
Collaborator

Apparently fixed by bde2cdc

@andypugh andypugh closed this Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants