OpenGL micro-freezes for seconds during layer switching or new tracks

Bug #1701936 reported by Kristoffer
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Undecided
Unassigned

Bug Description

If I use the openGl mode. It gets superslow using pcbnew. I mean slow as in changing the topmost layer or starting a new track takes around 6 seconds. So much time that I can manually go into GDB pause and get a stacktrace that looks like this, very easily reproduced:

#0 0x00007ffff3697c47 in ioctl () at /usr/lib/libc.so.6
#1 0x00007fffd5710988 in drmIoctl () at /usr/lib/libdrm.so.2
#2 0x00007fffd3eb4459 in amdgpu_cs_query_fence_status () at /usr/lib/libdrm_amdgpu.so.1
#3 0x00007fffd50566de in () at /usr/lib/xorg/modules/dri/radeonsi_dri.so
#4 0x00007fffd50557e8 in () at /usr/lib/xorg/modules/dri/radeonsi_dri.so
#5 0x00007fffd5055cec in () at /usr/lib/xorg/modules/dri/radeonsi_dri.so
#6 0x00007fffd507cc45 in () at /usr/lib/xorg/modules/dri/radeonsi_dri.so
#7 0x00007fffd4b08d74 in () at /usr/lib/xorg/modules/dri/radeonsi_dri.so
#8 0x00007fffd49831d4 in () at /usr/lib/xorg/modules/dri/radeonsi_dri.so
#9 0x00007fffd4983aca in () at /usr/lib/xorg/modules/dri/radeonsi_dri.so
#10 0x00007fffd7582e6e in KIGFX::CACHED_CONTAINER::Map() (this=0x4fdf0d0) at /home/krille/projects/kicad/common/gal/opengl/cached_container.cpp:234
#11 0x00007fffd7571903 in KIGFX::VERTEX_MANAGER::Map() (this=0x4fded80) at /home/krille/projects/kicad/common/gal/opengl/vertex_manager.cpp:54
#12 0x00007fffd7560f5f in KIGFX::OPENGL_GAL::BeginUpdate() (this=0x39f0c70) at /home/krille/projects/kicad/common/gal/opengl/opengl_gal.cpp:389
#13 0x00007fffd74b7729 in KIGFX::VIEW::ChangeLayerDepth(int, int) (this=0x33407d0, aLayer=109, aDepth=8) at /home/krille/projects/kicad/common/view/view.cpp:730
#14 0x00007fffd74b7bd6 in KIGFX::VIEW::UpdateAllLayersOrder() (this=0x33407d0) at /home/krille/projects/kicad/common/view/view.cpp:821
#15 0x00007fffd70a0d98 in PCB_DRAW_PANEL_GAL::SetTopLayer(PCB_LAYER_ID) (this=0x209d850, aLayer=F_Cu) at /home/krille/projects/kicad/pcbnew/pcb_draw_panel_gal.cpp:278
#16 0x00007fffd70a095c in PCB_DRAW_PANEL_GAL::SetHighContrastLayer(PCB_LAYER_ID) (this=0x209d850, aLayer=F_Cu) at /home/krille/projects/kicad/pcbnew/pcb_draw_panel_gal.cpp:185
#17 0x00007fffd70a21b2 in PCB_DRAW_PANEL_GAL::SetHighContrastLayer(int) (this=0x209d850, aLayer=0) at /home/krille/projects/kicad/pcbnew/pcb_draw_panel_gal.h:72
#18 0x00007fffd6e38073 in PCB_EDIT_FRAME::SetActiveLayer(PCB_LAYER_ID) (this=0x2049af0, aLayer=F_Cu) at /home/krille/projects/kicad/pcbnew/pcbframe.cpp:896
#19 0x00007fffd6e5dbfd in PCB_LAYER_WIDGET::OnLayerSelect(int) (this=0x35563b0, aLayer=0) at /home/krille/projects/kicad/pcbnew/class_pcb_layer_widget.cpp:471
#20 0x00007fffd704d7a9 in LAYER_WIDGET::OnLeftDownLayers(wxMouseEvent&) (this=0x35563b0, event=...) at /home/krille/projects/kicad/pcbnew/layer_widget.cpp:122
#21 0x00007ffff65685be in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#22 0x00007ffff65689ca in wxEvtHandler::SearchDynamicEventTable(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#23 0x00007ffff6568a5f in wxEvtHandler::TryHereOnly(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#24 0x00007ffff6568b13 in wxEvtHandler::ProcessEventLocally(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#25 0x00007ffff6568b75 in wxEvtHandler::ProcessEvent(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#26 0x00007ffff65688d7 in wxEvtHandler::SafelyProcessEvent(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#27 0x00007ffff6cdf47d in () at /usr/lib/libwx_gtk2u_core-3.0.so.0
#28 0x00007ffff30a37ac in () at /usr/lib/libgtk-x11-2.0.so.0
#29 0x00007ffff2a7aead in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#30 0x00007ffff2a8d4ee in () at /usr/lib/libgobject-2.0.so.0
#31 0x00007ffff2a9566f in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#32 0x00007ffff2a966ef in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#33 0x00007ffff31bb8cc in () at /usr/lib/libgtk-x11-2.0.so.0
#34 0x00007ffff30a1f74 in gtk_propagate_event () at /usr/lib/libgtk-x11-2.0.so.0
#35 0x00007ffff30a232b in gtk_main_do_event () at /usr/lib/libgtk-x11-2.0.so.0
#36 0x00007ffff2d1946c in () at /usr/lib/libgdk-x11-2.0.so.0
#37 0x00007ffff1fefa47 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#38 0x00007ffff1fefc78 in () at /usr/lib/libglib-2.0.so.0
#39 0x00007ffff1feff92 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#40 0x00007ffff30a13a7 in gtk_main () at /usr/lib/libgtk-x11-2.0.so.0
#41 0x00007ffff6cbe865 in wxGUIEventLoop::DoRun() () at /usr/lib/libwx_gtk2u_core-3.0.so.0
#42 0x00007ffff6427ae3 in wxEventLoopBase::Run() () at /usr/lib/libwx_baseu-3.0.so.0
#43 0x00007ffff63ef876 in wxAppConsoleBase::MainLoop() () at /usr/lib/libwx_baseu-3.0.so.0
#44 0x0000000000465002 in APP_KICAD::OnRun() (this=0x7f0400) at /home/krille/projects/kicad/kicad/kicad.cpp:256
#45 0x00007ffff6479427 in wxEntry(int&, wchar_t**) () at /usr/lib/libwx_baseu-3.0.so.0
#46 0x0000000000463b89 in main(int, char**) (argc=1, argv=0x7fffffffe528) at /home/krille/projects/kicad/kicad/kicad.cpp:288

This is the Kicad version information:

Application: kicad
Version: (2017-07-02 revision f074b5709)-master, debug build
Libraries: wxWidgets 3.0.3
           libcurl/7.54.1 OpenSSL/1.1.0f zlib/1.2.11 libpsl/0.17.0 (+libicu/59.1) libssh2/1.8.0 nghttp2/1.23.1
Platform: Linux 4.9.34-1-MANJARO x86_64, 64 bit, Little endian, wxGTK
- Build Info -
wxWidgets: 3.0.3 (wchar_t,wx containers,compatible with 2.8)
Boost: 1.64.0
Curl: 7.54.1
KiCad - Compiler: GCC 7.1.1 with C++ ABI 1011
        Settings: USE_WX_GRAPHICS_CONTEXT=OFF
                  USE_WX_OVERLAY=OFF
                  KICAD_SCRIPTING=OFF
                  KICAD_SCRIPTING_MODULES=OFF
                  KICAD_SCRIPTING_WXPYTHON=OFF
                  KICAD_SCRIPTING_ACTION_MENU=OFF
                  BUILD_GITHUB_PLUGIN=ON
                  KICAD_USE_OCE=ON

Revision history for this message
Eldar Khayrullin (eldar) wrote :
tags: added: gal pcbnew performance
Revision history for this message
Maciej Suminski (orsonmmz) wrote :

Does it depend on the board size? Has the problem started occurring with a recent change?

Revision history for this message
Kristoffer (kristoffer-odmark) wrote :

No difference on board size. The problem has been a while. It doesnt happen on my laptop that has a different gpu. But neither does it happen on stable 4.06. Went back to d9260d42c8a5b49c50603db705b191c799bc7144 and the same there.

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

Hi Kristoffer,

You're running open source radeon drivers. They are known to be extremely buggy, to the point that most commercial Linux software developers refuse support for them...

Tom

Revision history for this message
Kristoffer (kristoffer-odmark) wrote :

Hi Tom,

What drivers would you suggest I use then?

- Kristoffer

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

Are there proprietary drivers for your graphics card? I don't know if ATI/AMD still provides them for Linux. If you're running on a desktop PC, I'd suggest getting a cheapest NVidia card.

Tom

Revision history for this message
Kristoffer (kristoffer-odmark) wrote :

The amd drivers are all opensource, IE the old proprietary drivers are now the open source ones, the ones I am using. Also, this problem is not found in the stable releases of Kicad, so I guess there is a code change that causes it, and thus should be reversible

Changed in kicad:
status: New → Confirmed
Revision history for this message
Maciej Suminski (orsonmmz) wrote :

To find out what can be done, we need to pinpoint the cause. Unfortunately I do not have hardware that would let me investigate the problem, so I need your help here. Could you build and test the following commits:
- 01912aaabd9
- 431e3432013
- 2a276550ebf

Revision history for this message
Kristoffer (kristoffer-odmark) wrote : Re: [Bug 1701936] Re: OpenGL micro-freezes for seconds during layer switching or new tracks

I will test this when I get home from work tonight :)

On 07/13/2017 01:20 PM, Maciej Sumiński wrote:
> To find out what can be done, we need to pinpoint the cause. Unfortunately I do not have hardware that would let me investigate the problem, so I need your help here. Could you build and test the following commits:
> - 01912aaabd9
> - 431e3432013
> - 2a276550ebf
>

--
  -Kristoffer

Revision history for this message
Kristoffer (kristoffer-odmark) wrote :

Had to downgrade into boost 1.60.04, then it built. But I tried some few
stuff. Will bisect further.

08b52131df8 - microfreezes present

01912aaabd9 - The opengl did not work at all here, but no microfreezes

431e3432013 - no problem here

2a276550ebf - didnt try

On 2017-07-13 13:20, Maciej Sumiński wrote:
> To find out what can be done, we need to pinpoint the cause. Unfortunately I do not have hardware that would let me investigate the problem, so I need your help here. Could you build and test the following commits:
> - 01912aaabd9
> - 431e3432013
> - 2a276550ebf
>

Revision history for this message
Kristoffer (kristoffer-odmark) wrote :

This is the first offending commit:
702be4903fc67eaa1fc9b893a9ffaf8ab1b224ad

The ones before that has some graphic bugs though like not showing
everything. but the microfreezes was not present.

On 2017-07-13 13:20, Maciej Sumiński wrote:
> To find out what can be done, we need to pinpoint the cause. Unfortunately I do not have hardware that would let me investigate the problem, so I need your help here. Could you build and test the following commits:
> - 01912aaabd9
> - 431e3432013
> - 2a276550ebf
>

Revision history for this message
Kristoffer (kristoffer-odmark) wrote :

Also, I get a lot of dialup boxes at the offending commit that says:

Error: unmapping vertices buffer: invalid value

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

Kristoffer, please test the attached patch. If it fixes the problem, then I will clean it up and apply to the master branch.

Revision history for this message
Kristoffer (kristoffer-odmark) wrote :
Download full text (6.9 KiB)

Will test as soon as I get back!

On Aug 4, 2017 16:41, "Maciej Sumiński" <email address hidden> wrote:

> Kristoffer, please test the attached patch. If it fixes the problem,
> then I will clean it up and apply to the master branch.
>
> ** Patch added: "0001-Fixes-for-video-cards-unable-to-use-gl-Un-MapBuffer-
> .patch"
> https://bugs.launchpad.net/kicad/+bug/1701936/+
> attachment/4927087/+files/0001-Fixes-for-video-cards-
> unable-to-use-gl-Un-MapBuffer-.patch
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1701936
>
> Title:
> OpenGL micro-freezes for seconds during layer switching or new tracks
>
> Status in KiCad:
> Confirmed
>
> Bug description:
> If I use the openGl mode. It gets superslow using pcbnew. I mean slow
> as in changing the topmost layer or starting a new track takes around
> 6 seconds. So much time that I can manually go into GDB pause and get
> a stacktrace that looks like this, very easily reproduced:
>
> #0 0x00007ffff3697c47 in ioctl () at /usr/lib/libc.so.6
> #1 0x00007fffd5710988 in drmIoctl () at /usr/lib/libdrm.so.2
> #2 0x00007fffd3eb4459 in amdgpu_cs_query_fence_status () at
> /usr/lib/libdrm_amdgpu.so.1
> #3 0x00007fffd50566de in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #4 0x00007fffd50557e8 in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #5 0x00007fffd5055cec in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #6 0x00007fffd507cc45 in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #7 0x00007fffd4b08d74 in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #8 0x00007fffd49831d4 in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #9 0x00007fffd4983aca in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #10 0x00007fffd7582e6e in KIGFX::CACHED_CONTAINER::Map()
> (this=0x4fdf0d0) at /home/krille/projects/kicad/common/gal/opengl/cached_
> container.cpp:234
> #11 0x00007fffd7571903 in KIGFX::VERTEX_MANAGER::Map() (this=0x4fded80)
> at /home/krille/projects/kicad/common/gal/opengl/vertex_manager.cpp:54
> #12 0x00007fffd7560f5f in KIGFX::OPENGL_GAL::BeginUpdate()
> (this=0x39f0c70) at /home/krille/projects/kicad/
> common/gal/opengl/opengl_gal.cpp:389
> #13 0x00007fffd74b7729 in KIGFX::VIEW::ChangeLayerDepth(int, int)
> (this=0x33407d0, aLayer=109, aDepth=8) at /home/krille/projects/kicad/
> common/view/view.cpp:730
> #14 0x00007fffd74b7bd6 in KIGFX::VIEW::UpdateAllLayersOrder()
> (this=0x33407d0) at /home/krille/projects/kicad/common/view/view.cpp:821
> #15 0x00007fffd70a0d98 in PCB_DRAW_PANEL_GAL::SetTopLayer(PCB_LAYER_ID)
> (this=0x209d850, aLayer=F_Cu) at /home/krille/projects/kicad/
> pcbnew/pcb_draw_panel_gal.cpp:278
> #16 0x00007fffd70a095c in PCB_DRAW_PANEL_GAL::SetHighContrastLayer(PCB_LAYER_ID)
> (this=0x209d850, aLayer=F_Cu) at /home/krille/projects/kicad/
> pcbnew/pcb_draw_panel_gal.cpp:185
> #17 0x00007fffd70a21b2 in PCB_DRAW_PANEL_GAL::SetHighContrastLayer(int)
> (this=0x209d850, aLayer=0) at /home/krille/projects/kicad/
> pcbnew/pcb_draw_panel_gal.h:72
> #18 0x00007fffd6e38073 in PCB_EDIT_FRAME::SetActiveLayer(PCB...

Read more...

Revision history for this message
pipe (pipatron) wrote :

I had exactly the same symptoms. After applying this patch, the delay has now gone down to about 0.5 seconds instead of about 10. Haven't seen any drawbacks so far.

Revision history for this message
Kristoffer (kristoffer-odmark) wrote :

I tried the patch, It doesnt fix the problem for me.

Here is an small outline of a perf report I made following hauptmech method from the ML

+ 93.57% 0.00% kicad [unknown] [.] 0000000000000000
+ 92.82% 0.00% kicad [unknown] [.] 0x4840ec8348535554
+ 92.82% 0.00% kicad radeonsi_dri.so [.] 0xffff8064bbbbcc40
+ 92.82% 92.82% kicad libc-2.25.so [.] __memmove_avx_unaligned_erms
+ 5.54% 0.04% kicad libwx_baseu-3.0.so.0.3.0 [.] wxEvtHandler::ProcessEventIfMatchesId
+ 3.71% 0.00% kicad _pcbnew.kiface [.] LAYER_WIDGET::OnLeftDownLayers
+ 3.71% 0.00% kicad _pcbnew.kiface [.] PCB_LAYER_WIDGET::OnLayerSelect
+ 3.71% 0.00% kicad _pcbnew.kiface [.] PCB_EDIT_FRAME::SetActiveLayer
+ 3.71% 0.00% kicad _pcbnew.kiface [.] PCB_DRAW_PANEL_GAL::SetHighContrastLayer
+ 3.71% 0.00% kicad _pcbnew.kiface [.] PCB_DRAW_PANEL_GAL::SetHighContrastLayer

Revision history for this message
Maarten Bakker (maartenjb) wrote :

Hi, I've got the same problem, and want to try the patch as well, can someone tell me how I can apply this patch to my source directory?

Thanks!

Revision history for this message
pipe (pipatron) wrote :

I just downloaded the patch to my git source tree, made a new branch:

$ git checkout -b mapbuffer

And then applied it using git:

$ git apply 0001-Fixes-for-video-cards-unable-to-use-gl-Un-MapBuffer-.patch

I don't know if this is The Right Way™ but it worked. :)

Revision history for this message
Maarten Bakker (maartenjb) wrote :

Hi, Thanks, that worked. I did just download the file into de source directory and run the fix like you said.

Startup time of pcbnew and the footprint editor is now much faster, almost instant.

Drawing a line is faster as well, it is now taking 2 seconds instead of 10.

Revision history for this message
Kristoffer (kristoffer-odmark) wrote :
Download full text (3.3 KiB)

If I do the same and halt the program using GDB, this is the backtrace after patch:

#0 0x00007f64dec41a10 in __memmove_avx_unaligned_erms () at /usr/lib/libc.so.6
#1 0x00007f64bcd35cef in () at /usr/lib/xorg/modules/dri/radeonsi_dri.so
#2 0x00007f64bc7d3560 in () at /usr/lib/xorg/modules/dri/radeonsi_dri.so
#3 0x00007f64bc647821 in () at /usr/lib/xorg/modules/dri/radeonsi_dri.so
#4 0x00007f64bc647a08 in () at /usr/lib/xorg/modules/dri/radeonsi_dri.so
#5 0x00007f64c3574bdc in KIGFX::CACHED_CONTAINER_RAM::Unmap() (this=0x104b7c9f0) at /home/krille/projects/kicad/common/gal/opengl/cached_container_ram.cpp:80
#6 0x00007f64c3560dbd in KIGFX::VERTEX_MANAGER::Unmap() (this=0x104b7c6a0) at /home/krille/projects/kicad/common/gal/opengl/vertex_manager.cpp:60
#7 0x00007f64c354f181 in KIGFX::OPENGL_GAL::EndUpdate() (this=0x1035a78e0) at /home/krille/projects/kicad/common/gal/opengl/opengl_gal.cpp:398
#8 0x00007f64c3494c08 in KIGFX::VIEW::ChangeLayerDepth(int, int) (this=0x102eb0cd0, aLayer=176, aDepth=176) at /home/krille/projects/kicad/common/view/view.cpp:733
#9 0x00007f64c34950f5 in KIGFX::VIEW::UpdateAllLayersOrder() (this=0x102eb0cd0) at /home/krille/projects/kicad/common/view/view.cpp:821
#10 0x00007f64c3031243 in PCB_DRAW_PANEL_GAL::SetTopLayer(PCB_LAYER_ID) (this=0x101c0d550, aLayer=In1_Cu) at /home/krille/projects/kicad/pcbnew/pcb_draw_panel_gal.cpp:278
#11 0x00007f64c3030daf in PCB_DRAW_PANEL_GAL::SetHighContrastLayer(PCB_LAYER_ID) (this=0x101c0d550, aLayer=In1_Cu) at /home/krille/projects/kicad/pcbnew/pcb_draw_panel_gal.cpp:186
#12 0x00007f64c30327d2 in PCB_DRAW_PANEL_GAL::SetHighContrastLayer(int) (this=0x101c0d550, aLayer=1) at /home/krille/projects/kicad/pcbnew/pcb_draw_panel_gal.h:72
#13 0x00007f64c2daebed in PCB_EDIT_FRAME::SetActiveLayer(PCB_LAYER_ID) (this=0x101bfae70, aLayer=In1_Cu) at /home/krille/projects/kicad/pcbnew/pcbframe.cpp:894
#14 0x00007f64c2dd8337 in PCB_LAYER_WIDGET::OnLayerSelect(int) (this=0x1030c8620, aLayer=1) at /home/krille/projects/kicad/pcbnew/class_pcb_layer_widget.cpp:580
#15 0x00007f64c2fdd45e in LAYER_WIDGET::OnLeftDownLayers(wxMouseEvent&) (this=0x1030c8620, event=...) at /home/krille/projects/kicad/pcbnew/layer_widget.cpp:122
#16 0x00007f64e1ac55be in wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#17 0x00007f64e1ac59ca in wxEvtHandler::SearchDynamicEventTable(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#18 0x00007f64e1ac5a5f in wxEvtHandler::TryHereOnly(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#19 0x00007f64e1ac5b13 in wxEvtHandler::ProcessEventLocally(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#20 0x00007f64e1ac5b75 in wxEvtHandler::ProcessEvent(wxEvent&) () at /usr/lib/libwx_baseu-3.0.so.0
#21 0x00007f64e1ac6cc2 in wxEvtHandler::ProcessPendingEvents() () at /usr/lib/libwx_baseu-3.0.so.0
#22 0x00007f64e194aa77 in wxAppConsoleBase::ProcessPendingEvents() () at /usr/lib/libwx_baseu-3.0.so.0
#23 0x00007f64e21fc4fd in wxApp::DoIdle() () at /usr/lib/libwx_gtk2u_core-3.0.so.0
#24 0x00007f64e21fc623 in () at /usr/lib/libwx_gtk2u_core-3.0.so.0
#25 0x00007f64dd54c8c5 in g_main_context_dispatch () at /usr/lib/l...

Read more...

Revision history for this message
pipe (pipatron) wrote :

The current status is a bit weird now.

There was a commit named: "262fcc91a Fixes for video cards unable to use gl{Un,}MapBuffer correctly"

After this commit, the patch in this bug can no longer be applied. That's not necessarily bad, if it is the same patch that was offered in this bug report.

However, the commit does not solve the freezes.

Applying the patch to the previous commit "46b5575c5 OpenGL driver debug routines" solves the freezes.

So:

46b5575c5 + patch = helps
46b5575c5 -> 262fcc91a = does not help, and prevents further patching

Revision history for this message
pipe (pipatron) wrote :

After mentioning that my card is actually nvidia, I received a patch on IRC.

Applying the patch to the previously "broken" commit 262fcc91a fixes the problem for me (mostly).

The patch is here: https://pastebin.com/raw/KgAVSeJD

Note 1: "git apply" thought that the patch was broken, I don't know why so I just changed the source code. It's just a test for AMD that should be removed.

Note 2: Even with this patch, there is still about a 1 second delay between clicking on a pin to start routing a track, and when the track actually appears. After that everything is smooth. This is of course still very annoying, but I attribute that delay to me having a 10 year old computer.

Revision history for this message
tistructor (tistructor) wrote :

My vendor string is not amd and in function
VERTEX_CONTAINER * VERTEX_CONTAINER :: MakeContainer (bool aCached)
{
     If (aCached)
     {
         Const unsigned char * vendor = glGetString (GL_VENDOR);

         // AMD / ATI cards do not cope well with GPU memory mapping,
         // so the vertex data has to be kept in RAM
         If (strstr ((const char *) vendor, "AMD"))
             Return new CACHED_CONTAINER_RAM;
         else
             Return new CACHED_CONTAINER_GPU;
     }

     Return new NONCACHED_CONTAINER;
}

Return new NONCACHED_CONTAINER;

Modifying the function so that the function returns new CACHED_CONTAINER_RAM
Compiling pcbnew works well in opengl.

glxinfo | grep -i opengl
OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD PALM (DRM 2.49.0 / 4.10.0-32-generic, LLVM 4.0.0)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 17.0.7
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 17.0.7
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 17.0.7
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:

Revision history for this message
tistructor (tistructor) wrote :

With this pcbnew modification works well in opengl.

VERTEX_CONTAINER* VERTEX_CONTAINER::MakeContainer( bool aCached )
{
    if( aCached )
    {
        const unsigned char* vendor = glGetString( GL_VENDOR );

        // AMD/ATI cards do not cope well with GPU memory mapping,
        // so the vertex data has to be kept in RAM
        if( strstr( (const char*) vendor, "AMD" ) )
            return new CACHED_CONTAINER_RAM;
        else if( strstr( (const char*) vendor, "X.Org" ) )
     return new CACHED_CONTAINER_RAM;
        else
            return new CACHED_CONTAINER_GPU;
    }

    return new NONCACHED_CONTAINER;
}

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

@tistructor Thank you for taking time to investigate the problem further. The only problem here is you are mixing the vendor strings returned by glxinfo and glewinfo. One calls an OpenGL function (glGetString( GL_VENDOR )) [1], the other one queries the X server [2]. The second one is not portable, that is why I decided to use the OpenGL call.

Can you tell me what you get by calling 'glewinfo | grep Running'? What video card do you have? If this is an ATI/AMD card, can you verify VERTEX_CONTAINER::MakeContainer() returns a CACHED_CONTAINER_RAM object?

1. https://github.com/mravella/hair/blob/master/src/glewinfo.c#L10474
2. https://github.com/tdz/gtkglext/blob/master/examples/glxinfo.c#L291

Revision history for this message
Cristiano Rodrigues (microcris) wrote :

'glewinfo | grep Running' gives me this:

Running on a AMD CAICOS (DRM 2.50.0 / 4.13.0-rc5-amd64, LLVM 4.0.1) from X.Org

The present bug and this bug (https://bugs.launchpad.net/kicad/+bug/1708455) if not the same, they must be related

Revision history for this message
Eldar Khayrullin (eldar) wrote :

The same problem:
'Route track', 'Change layer', 'Color picker' the pcbnew has timeout (5-7 seconds).

'glewinfo | grep Running' gives:
Running on a Gallium 0.4 on AMD RV770 (DRM 2.49.0 / 4.10.0-32-generic, LLVM 4.0.0) from X.Org

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

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

Changed in kicad:
status: Confirmed → Fix Committed
Revision history for this message
Maciej Suminski (orsonmmz) wrote :

@tistructor,

You are right about the "X.Org" string. Thank you for the hint, it helped me patch the problems.

Revision history for this message
Kristoffer (kristoffer-odmark) wrote :
Download full text (6.6 KiB)

Thank you!

On Aug 21, 2017 16:31, "Maciej Suminski" <email address hidden> wrote:

> @tistructor,
>
> You are right about the "X.Org" string. Thank you for the hint, it
> helped me patch the problems.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1701936
>
> Title:
> OpenGL micro-freezes for seconds during layer switching or new tracks
>
> Status in KiCad:
> Fix Committed
>
> Bug description:
> If I use the openGl mode. It gets superslow using pcbnew. I mean slow
> as in changing the topmost layer or starting a new track takes around
> 6 seconds. So much time that I can manually go into GDB pause and get
> a stacktrace that looks like this, very easily reproduced:
>
> #0 0x00007ffff3697c47 in ioctl () at /usr/lib/libc.so.6
> #1 0x00007fffd5710988 in drmIoctl () at /usr/lib/libdrm.so.2
> #2 0x00007fffd3eb4459 in amdgpu_cs_query_fence_status () at
> /usr/lib/libdrm_amdgpu.so.1
> #3 0x00007fffd50566de in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #4 0x00007fffd50557e8 in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #5 0x00007fffd5055cec in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #6 0x00007fffd507cc45 in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #7 0x00007fffd4b08d74 in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #8 0x00007fffd49831d4 in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #9 0x00007fffd4983aca in () at /usr/lib/xorg/modules/dri/
> radeonsi_dri.so
> #10 0x00007fffd7582e6e in KIGFX::CACHED_CONTAINER::Map()
> (this=0x4fdf0d0) at /home/krille/projects/kicad/common/gal/opengl/cached_
> container.cpp:234
> #11 0x00007fffd7571903 in KIGFX::VERTEX_MANAGER::Map() (this=0x4fded80)
> at /home/krille/projects/kicad/common/gal/opengl/vertex_manager.cpp:54
> #12 0x00007fffd7560f5f in KIGFX::OPENGL_GAL::BeginUpdate()
> (this=0x39f0c70) at /home/krille/projects/kicad/
> common/gal/opengl/opengl_gal.cpp:389
> #13 0x00007fffd74b7729 in KIGFX::VIEW::ChangeLayerDepth(int, int)
> (this=0x33407d0, aLayer=109, aDepth=8) at /home/krille/projects/kicad/
> common/view/view.cpp:730
> #14 0x00007fffd74b7bd6 in KIGFX::VIEW::UpdateAllLayersOrder()
> (this=0x33407d0) at /home/krille/projects/kicad/common/view/view.cpp:821
> #15 0x00007fffd70a0d98 in PCB_DRAW_PANEL_GAL::SetTopLayer(PCB_LAYER_ID)
> (this=0x209d850, aLayer=F_Cu) at /home/krille/projects/kicad/
> pcbnew/pcb_draw_panel_gal.cpp:278
> #16 0x00007fffd70a095c in PCB_DRAW_PANEL_GAL::SetHighContrastLayer(PCB_LAYER_ID)
> (this=0x209d850, aLayer=F_Cu) at /home/krille/projects/kicad/
> pcbnew/pcb_draw_panel_gal.cpp:185
> #17 0x00007fffd70a21b2 in PCB_DRAW_PANEL_GAL::SetHighContrastLayer(int)
> (this=0x209d850, aLayer=0) at /home/krille/projects/kicad/
> pcbnew/pcb_draw_panel_gal.h:72
> #18 0x00007fffd6e38073 in PCB_EDIT_FRAME::SetActiveLayer(PCB_LAYER_ID)
> (this=0x2049af0, aLayer=F_Cu) at /home/krille/projects/kicad/
> pcbnew/pcbframe.cpp:896
> #19 0x00007fffd6e5dbfd in PCB_LAYER_WIDGET::OnLayerSelect(int)
> (this=0x35563b0, aLayer=0) at /home/krille/projects/kicad/
> pcbnew/class_pcb_layer_widget.cpp:...

Read more...

Revision history for this message
tistructor (tistructor) wrote :

Thank you!

I was in vacation.

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.