bugGNU Octave - Bugs: bug #65632, legend produces patch error due to...

 
 

bug #65632: legend produces patch error due to cdata size mismatch

Submitter:  Dmitri A. Sergatskov <dasergatskov>
Submitted:  Tue 23 Apr 2024 08:42:54 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Ready For Test Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 9.1.0 Operating System:  * Any
Fixed Release:  None Planned Release:  9.2.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 11 May 2024 05:19:23 PM UTC, comment #11: 

These are the kinds of tests I've been slowly looking to write in quiver, patch, now bar/barh.  They're cumbersome, require diving into graphics handle properties and hoping something is consistent enough to check.  Legend has also been trickier than others judging from all of the reports over the past years. 

I think I had added a general note about adding more graphics tests like that in the wiki projects list. But generally have just been doing that alongside other function work. It can go on the to do list.  No need to track here

Nicholas Jankowski <nrjank>
Group Member
Sat 11 May 2024 01:10:08 PM UTC, comment #10: 

Thank you for checking the patch.
I pushed it to the stable branch (since it fixes a regression from Octave 8):
https://hg.savannah.gnu.org/hgweb/octave/rev/54d87fbbb421

Marking as ready for test.

@Nik: You are right. There are a lot of demos for `legend.m`. And I guess many of them are meant to check the functionality of `legend.m` rather than demonstrating how to use it. With that in mind, it might make sense to convert them to BISTs.
However, many (all?) of those demos require manual inspection (like: Are/Is the main axes correctly aligned after displaying the legend? Is the legend displayed at the expected location? With the expected entries? Is the legend text correctly formatted (TeX)? Is it displayed with the expected color? Does the legend "key" match the corresponding object in the main axes? ...)
Maybe, some of those tests can be automated? But it might be better to track that in a different report if we'd like to do that...

Markus Mützel <mmuetzel>
Group administrator
Fri 10 May 2024 05:06:45 PM UTC, comment #9: 

trying different combinations of legend calls and set() changes to color data, this seems to solve the problem for any patch or surf objects.

previously it would pass whatever color data the patch/surf had to  _go_patch_ which creates a dummy 3-point patch object (the same as running h=patch()).  That geometry would rarely match the shape of the main figure's cdata, which now triggers an error.  the patch reduces this to a single cdata color value, which is all that the legend 'icon' should display anyway.  running a 2-d median should either pull a single median colormap value or dim-3 RGB value, which should cover all valid cdata shapes.

I don't know how matlab selects a legend color for multi-color patches, but this seems as valid as any. can always tweak that determination later if it needs to be adjusted.

Nicholas Jankowski <nrjank>
Group Member
Fri 10 May 2024 02:20:52 PM UTC, comment #8: 

also looks good. should the demo be tagged to a bug? e.g., the bug #61814 demo is marked and titled to let people know what it was created to test (e.g., no color warning / legend renders). 

(wow.  37+ demos in legend. maybe some can be made into BISTs?)

Nicholas Jankowski <nrjank>
Group Member
Fri 10 May 2024 01:13:22 PM UTC, comment #7: 

Looks good to me.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 10 May 2024 12:49:53 PM UTC, comment #6: 

The attached patch avoids the error from comment #0 for me by selecting the median cdata value for the legend entry of surface or patch objects.

It also adds a demo that shows a legend entry for a patch object.

Not tested extensively yet.


(file #56031)

Markus Mützel <mmuetzel>
Group administrator
Wed 24 Apr 2024 06:12:20 PM UTC, comment #5: 

confirming the issue occurs on 9.1.0 and not on 8.4.0.  legend in 8.4.0 is calling `__go_patch__` the same way in both versions, so the issue does seem related to changes in graphics.cc.  testing different revisions, that error started with
https://hg.savannah.gnu.org/hgweb/octave/rev/c4500208f280

that push was intended to prevent an octave crash from inconsistent user input to patch.  might take a bit more digging to see why legend's input to `__go_patch__` is breaking things.  that' buried in graphics.cc, though, so a bit tougher to step through and probe than the other m-code.

Nicholas Jankowski <nrjank>
Group Member
Tue 23 Apr 2024 09:57:29 PM UTC, comment #4: 

on default at line 1129 legend.m calls _go_patch_ (in graphics.cc) which throws the error.


 hicon = __go_patch__ (hl, [pprops; vals]{:});


the values of pprops are:


debug> pprops
            pprops =
            {
              [1,1] = edgecolor
              [1,2] = facecolor
              [1,3] = cdata
              [1,4] = linestyle
              [1,5] = linewidth
              [1,6] = marker
              [1,7] = markeredgecolor
              [1,8] = markerfacecolor
              [1,9] = markersize
            }


vals 1 and 2 are:

 vals(1:2)
            ans =
            {
              [1,1] =

                 0   0   0

              [1,2] = flat
            }

 size(vals{3})
            ans =

               49   49


bug #65431  did try to enforce better checking for patch color assignments that were triggering crashes, so it may be the way legend is creating a patch object (i guess it tries to create a new, similar patch object to get the 'icon' for the legend) is in violation of this?  later i should be able to compare the passed values between two versions to verify whether legend is doing anything different.

Nicholas Jankowski <nrjank>
Group Member
Tue 23 Apr 2024 09:32:46 PM UTC, comment #3: 

actually, i don't think the checks on that error changed with any of those fixes. maybe a recent change to legend is causing the problem, since that call is what's triggering the warning.

Nicholas Jankowski <nrjank>
Group Member
Tue 23 Apr 2024 08:57:08 PM UTC, comment #2: 

could be related to changes to patch in bug #65431

Nicholas Jankowski <nrjank>
Group Member
Tue 23 Apr 2024 08:52:29 PM UTC, comment #1: 

Also see the same problem on Windows with 9.1.0 release.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Tue 23 Apr 2024 08:42:54 PM UTC, original submission:  


octave:3> surf (peaks ())
octave:4> legend ("peaks()")
octave:5> warning: opengl_renderer: cdata does not match number of faces or number of vertices per face.  Not rendering.

octave:5> version
ans = 9.1.1
octave:6> version -hgid
ans = f428a432ed4f


Marker is missing in the legend (see attached).
It works as expected in 8.4.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #56031:  bug65632-legend-patch-cdata.patch added by mmuetzel (4KiB - application/octet-stream)
file #55962:  bad_legend.png added by dasergatskov (113KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by nrjank
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by dasergatskov (Submitted the item)
  •  

    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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-05-11 mmuetzel StatusPatch Submitted Ready For Test
    2024-05-10 mmuetzel Attached File- Added bug65632-legend-patch-cdata.patch, #56031
        StatusConfirmed Patch Submitted
        Planned ReleaseNone 9.2.0
    2024-04-24 nrjank StatusNone Confirmed
        Releasestable 9.1.0
        Operating SystemGNU/Linux Any
        Summarylegend does not show marker in 3d plots legend produces patch error due to cdata size mismatch
        Carbon-Copy- Added mmuetzel
    2024-04-23 dasergatskov Attached File- Added bad_legend.png, #55962

    Back to the top

    Powered by Savane 3.13-3e34.
    Corresponding source code