Strange (incorrect) display in Gal canvas for pad editor dialog and footprint editor.

Bug #1817284 reported by jean-pierre charras
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
High
Seth Hillbrand

Bug Description

It happens only in Opengl mode and only on Windows.
It was introduced by the pixel alignment changes.

When the view in the GAL canvas is built before the dialog or frame is actually shown on screen, only some graphic items are visible.
This is always the case for the dialog pad editor,
and when the footprint editor is called by Ctrl+E from a select footprint.

Filled polygons (rect, half circles) and net names on pads are visible.
Lines, segments and circles (filled or not) and not visible.

They become visible as soon as the GAL canvas is refreshed:
- resizing the dialog/frame
- changing anything in the panel (grill size, zoom ...)

I am currently unable to fix this issue (I have only a ugly workaround)
so I am asking for help from GAL gurus.
Thanks.

Changed in kicad:
importance: Undecided → High
Revision history for this message
Nick Østergaard (nickoe) wrote :

@jo, is this imtemded for rc2? Maybe we should add the milestone as well.

Changed in kicad:
milestone: none → 5.1.0-rc2
Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@JP, would you please include before and after screenshots showing the issue. I cannot duplicate this on my system in either 32 or 64 bit builds but maybe I'm missing something? @Tom, can you reproduce this? I see you set the milestone to rc2. Are you looking into this?

Revision history for this message
jean-pierre charras (jp-charras) wrote :
Revision history for this message
jean-pierre charras (jp-charras) wrote :
Revision history for this message
jean-pierre charras (jp-charras) wrote :
Revision history for this message
jean-pierre charras (jp-charras) wrote :
Revision history for this message
jean-pierre charras (jp-charras) wrote :
Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@JP, this definitely not what I am seeing. What version of windows are you running? I'm using windows 10 so there may be a difference between windows versions that is causing the issue.

Revision history for this message
Seth Hillbrand (sethh) wrote :

Does this happen with the packaged builds as well?

Revision history for this message
jean-pierre charras (jp-charras) wrote :

It happens also with the packaged builds.

My usual version:

Application: kicad
Version: (5.1.0-rc1-124-gaca183561-dirty), debug build
Libraries:
    wxWidgets 3.1.1
    libcurl/7.50.3 OpenSSL/1.0.2j zlib/1.2.8 libidn/1.33 libssh2/1.7.0 nghttp2/1.15.0 librtmp/2.3
Platform: Windows 7 (build 7601, Service Pack 1), 32 bit, Little endian, wxMSW
Build Info:
    wxWidgets: 3.1.1 (wchar_t,wx containers)
    Boost: 1.63.0
    OpenCASCADE Community Edition: 6.8.0
    Curl: 7.53.1
    Compiler: GCC 6.3.0 with C++ ABI 1010

Build settings:
    USE_WX_GRAPHICS_CONTEXT=OFF
    USE_WX_OVERLAY=OFF
    KICAD_SCRIPTING=ON
    KICAD_SCRIPTING_MODULES=ON
    KICAD_SCRIPTING_PYTHON3=OFF
    KICAD_SCRIPTING_WXPYTHON=OFF
    KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
    KICAD_SCRIPTING_ACTION_MENU=ON
    BUILD_GITHUB_PLUGIN=ON
    KICAD_USE_OCE=ON
    KICAD_USE_OCC=OFF
    KICAD_SPICE=ON

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

Does any one else have a windows 7 system that can confirm this? I would really like to tag rc2 today but this bug needs to be fixed unless it is a video driver issue or something of that nature.

Revision history for this message
jean-pierre charras (jp-charras) wrote :

@Wayne,
I don't know if it is a video driver issue, but I can commit a workaround:
The workaround is just calling a view refresh 200ms after the dialog is displayed, using a timer.
This is a small fix, before really fixing this issue.

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

@JP, this should be the last resort solution but if there is not a better way than I'm fine with this. It seems to me that posting some type of repaint event would be a better solution so that the update would happen immediately after the dialog is realized but maybe I'm being overly optimistic about this solution.

Revision history for this message
Seth Hillbrand (sethh) wrote :

Is this possibly related to lp:1816492 ? Also strange icon display and Windows 7

Revision history for this message
Tomasz Wlostowski (twlostow) wrote :

Hi @JP,

(came back from the weekend, hence so late...)

Could you check with a debugger or printfs() if the shaders are given correct parameters prior to resizing/redrawing the view? The code is on opengl_gal line 484 onwards:

    shader->Use();
    shader->SetParameter( ufm_worldPixelSize, (float) getWorldPixelSize() / GetBackingScaleFactor() );
    shader->SetParameter( ufm_screenPixelSize, getScreenPixelSize() );
    double pixelSizeMultiplier = compositor->GetAntialiasSupersamplingFactor();
    shader->SetParameter( ufm_pixelSizeMultiplier, (float) pixelSizeMultiplier );
    shader->Deactivate();

I'm interested if values of getWorldPixelSize(), etc are meaningful. Maybe something is not in sync, causing some items to disappear.

Thanks,
Tom

Revision history for this message
jean-pierre charras (jp-charras) wrote :

Hi @Tomasz,

printf does not show bad parameters.

After more tests, I am now pretty sure the root issue is some interaction between 2 instances of OPENGL_GAL, and happens just after the second instance is created.

It happens of course when opening the pad editor or the footprint editor, but also when switching the GAL canvas to OpenGL, if an other OPENGL_GAL is running.
For instance if both the board editor and the fp editor are open, if I switch the fp editor from Cairo to Opengl, I also see the incorrect display.
(The opposite is true: if I switch the board editor from Cairo to Opengl, I also see the incorrect display)
I tested there is no issue in pad editor if the board editor uses Cairo, and the pad editor uses OpenGL (need a code change).

No problem if only one OPENGL_GAL is running.

I am thinking any object using something else than Shader( SHADER_NONE ) is not shown when the view is built just after the new OPENGL_GAL instance is created, and could be due to some strange caching issue.
The first change (grid or zoom change) displays the right view.

If built more than 200 ms after the opengl canvas is shown on screen (just a refresh is not always enough) the display is OK.

Revision history for this message
Seth Hillbrand (sethh) wrote :

@JP- Can you try the attached patch as see if it fixes your issue?

Revision history for this message
jean-pierre charras (jp-charras) wrote :

Yes, it fixes this issue!
Seth, you are a Genius.

Revision history for this message
KiCad Janitor (kicad-janitor) wrote :

Fixed in revision 269f420f8d338b1193c94f838eff2916d42d83bc
https://git.launchpad.net/kicad/patch/?id=269f420f8d338b1193c94f838eff2916d42d83bc

Changed in kicad:
status: New → Fix Committed
assignee: nobody → Seth Hillbrand (sethh)
Revision history for this message
Seth Hillbrand (sethh) wrote :

Oh good. I've pushed a slightly revised version that properly deletes shaders as well.

@Tomasz- Do you see any issue with keeping shaders separate for each OpenGL instance?

Revision history for this message
Tomasz Wlostowski (twlostow) wrote :

@Seth, chapeau bas! I think they should have been separate for each GL context from the beginning. I'm actually surprised it worked this way so fine for so long. Maybe some rare crashes/graphics issues were caused by this bug?

Tom

Revision history for this message
Maciej Suminski (orsonmmz) wrote :

Oh dear, you might have just fixed one of the oldest rendering bugs: https://bugs.launchpad.net/kicad/+bug/1782852
Thanks Seth!

Revision history for this message
Jeff Young (jeyjey) wrote : Re: [Bug 1817284] Re: Strange (incorrect) display in Gal canvas for pad editor dialog and footprint editor.

That would be big. I looked into that bug once upon a time, but it reproduced so infrequently that I gave up.

> On 25 Feb 2019, at 20:55, Maciej Suminski <email address hidden> wrote:
>
> Oh dear, you might have just fixed one of the oldest rendering bugs: https://bugs.launchpad.net/kicad/+bug/1782852
> Thanks Seth!
>
> --
> You received this bug notification because you are a member of KiCad Bug
> Squad, which is subscribed to KiCad.
> https://bugs.launchpad.net/bugs/1817284
>
> Title:
> Strange (incorrect) display in Gal canvas for pad editor dialog and
> footprint editor.
>
> Status in KiCad:
> Fix Committed
>
> Bug description:
> It happens only in Opengl mode and only on Windows.
> It was introduced by the pixel alignment changes.
>
> When the view in the GAL canvas is built before the dialog or frame is actually shown on screen, only some graphic items are visible.
> This is always the case for the dialog pad editor,
> and when the footprint editor is called by Ctrl+E from a select footprint.
>
> Filled polygons (rect, half circles) and net names on pads are visible.
> Lines, segments and circles (filled or not) and not visible.
>
> They become visible as soon as the GAL canvas is refreshed:
> - resizing the dialog/frame
> - changing anything in the panel (grill size, zoom ...)
>
> I am currently unable to fix this issue (I have only a ugly workaround)
> so I am asking for help from GAL gurus.
> Thanks.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/kicad/+bug/1817284/+subscriptions

Revision history for this message
Wayne Stambaugh (stambaughw) wrote :

It appears that lp:1544527 could fixed by this as well. It might not be a bad idea to dig around the bug tracker and see if there are any other bugs that can be closed out.

Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.