[GRASS-dev] [GRASS GIS] #3153: g.gui.animation freezes when trying to add decorations

#3153: g.gui.animation freezes when trying to add decorations
-----------------------------+-------------------------
Reporter: veroandreo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Keywords: g.gui.animation | CPU: Unspecified
Platform: Linux |
-----------------------------+-------------------------
g.gui.animation freezes when trying to add decorations and the only
possibility is to close it, loosing all the settings.

{{{
Traceback (most recent call last):
   File "/home/veroandreo/software/grass-7.3.svn/dist.x86_64-pc-linux-
gnu/gui/wxpython/animation/dialogs.py", line 1502, in OnExport
     decorations=self.GetDecorations())
   File "/home/veroandreo/software/grass-7.3.svn/dist.x86_64-pc-linux-
gnu/etc/python/grass/pydispatch/signal.py", line 229, in emit
     dispatcher.send(signal=self, *args, **kwargs)
   File "/home/veroandreo/software/grass-7.3.svn/dist.x86_64-pc-linux-
gnu/etc/python/grass/pydispatch/dispatcher.py", line 349, in send
     **named
   File "/home/veroandreo/software/grass-7.3.svn/dist.x86_64-pc-linux-
gnu/etc/python/grass/pydispatch/robustapply.py", line 60, in robustApply
     return receiver(*arguments, **named)
   File "/home/veroandreo/software/grass-7.3.svn/dist.x86_64-pc-linux-
gnu/gui/wxpython/animation/controller.py", line 610, in _export
     bgcolor, fgcolor).ConvertToImage()
   File "/home/veroandreo/software/grass-7.3.svn/dist.x86_64-pc-linux-
gnu/gui/wxpython/animation/utils.py", line 250, in RenderText
     w, h = dc.GetTextExtent(text)
   File "/usr/lib64/python2.7/site-packages/wx-3.0-gtk3/wx/_gdi.py", line
4127, in GetTextExtent
     return _gdi_.DC_GetTextExtent(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "m_graphicContext" failed at
./src/common/dcgraph.cpp(1147) in DoGetTextExtent():
wxGCDC(cg)::DoGetTextExtent - invalid DC
}}}

It would be useful to be able to export those settings or configurations
to keep them as templates, then, or so.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by annakrat):

I can't reproduce it with wxPython 3.0.2.0 on Ubuntu 16. What are the
exact steps and configuration?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/3153#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by veroandreo):

Sorry for the delay...

I just select a raster or vector time series to display, then go to
"export animation" and before actually exporting, I add some decoration,
i.e.: timestamp, image or text, and when I click over export, rather
nothing happens or "Preparing export, please wait..." sign freezes in the
screen forever, while in the output window, I get the same error as
reported before...

System info:

{{{
GRASS version: 7.3.svn
GRASS SVN revision: r69574M
Build date: 2016-09-26
Build platform: x86_64-pc-linux-gnu
GDAL: 2.0.2
PROJ.4: 4.9.2
GEOS: 3.5.0
SQLite: 3.13.0
Python: 2.7.12
wxPython: 3.0.2.0
Platform: Linux-4.7.4-200.fc24.x86_64-x86_64-with-fedora-24-Twenty_Four
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/3153#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by annakrat):

I still can't reproduce it, even with wxpython 3.0.2.0. First try using
different font, but I don't think that would help. Next try to apply this
change and recompile:

{{{
Index: animation/utils.py

--- animation/utils.py (revision 69577)
+++ animation/utils.py (working copy)
@@ -245,7 +245,7 @@

  def RenderText(text, font, bgcolor, fgcolor):
      """Renderes text with given font to bitmap."""
- dc = wx.MemoryDC()
+ dc = wx.MemoryDC(wx.EmptyBitmap(20, 20))
      dc.SetFont(font)
      w, h = dc.GetTextExtent(text)
      bmp = wx.EmptyBitmap(w + 2, h + 2)

}}}

I hope this could help, otherwise I have no idea.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by veroandreo):

Unfortunatelly, no... still same behaviour with a freshly updated trunk
r69591M :frowning: No idea

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/3153#comment:4&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by annakrat):

It might be something specific for Fedora. I hoped that diff could fix it,
but I am clueless now.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:5&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by neteler):

I have the same issue (also on F24). Any hints how to debug that?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/3153#comment:6&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by annakrat):

Replying to [comment:6 neteler]:
> I have the same issue (also on F24). Any hints how to debug that?

That diff is the only idea I have, please try it. You can also put there

{{{
print dc.IsOk()
}}}
before
{{{
w, h = dc.GetTextExtent(text)
}}}
to see if the dc is ok to use.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:7&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------
Changes (by neteler):

* Attachment "g_gui_animation_refresh_missing.jpg" added.

g.gui.animation: refresh missing

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/3153&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by neteler):

I applied the patch and it no longer freezes. The print patch did not have
any effect (nothing is printed).

I attach a screenshot to show that when enlarging the window black borders
come up which have a refresh issue when moving the legend around. Perhaps
related?

I'm using wxPython-3.0.2.0-10.fc24.x86_64.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:8&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by annakrat):

Replying to [comment:8 neteler]:
> I applied the patch and it no longer freezes. The print patch did not
have any effect (nothing is printed).

So do you confirm the patch solved the issue? Do the exported images/gif
and the text look correct?

> I attach a screenshot to show that when enlarging the window black
borders come up which have a refresh issue when moving the legend around.
Perhaps related?
>
Could be related, but it's a little bit different problem, please create a
new ticket.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:9&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by veroandreo):

I applied the patch. Buttons "Cancel" and "Export" still freeze when I add
decorations (i.e.: remain completely irresponsive) if I try to click on
them. Luckily, I can reach them by <Tab> and the animation is exported
correctly with the decorations I added. However in the teminal I get the
following:

{{{
/home/veroandreo/software/grass-7.3.svn/dist.x86_64-pc-linux-
gnu/etc/python/grass/imaging/images2gif.py:344: VisibleDeprecationWarning:
converting an array with ndim > 0 to an index will result in an error in
the future
   im2 = im[y0:y1, x0:x1]
}}}

If I do not add any decorations and only export the animation as-is
directly, buttons work fine. But I get the same warning in the terminal:

{{{
/home/veroandreo/software/grass-7.3.svn/dist.x86_64-pc-linux-
gnu/etc/python/grass/imaging/images2gif.py:344: VisibleDeprecationWarning:
converting an array with ndim > 0 to an index will result in an error in
the future
   im2 = im[y0:y1, x0:x1]
}}}

Tested with a STRDS in NC climatic Location. Grass trunk,
revision=r69647M. If you have any ideas, I'm happy to keep testing.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:10&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------
Changes (by neteler):

* Attachment "wx_animation.diff" added.

Patch from comment #3

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by annakrat):

I committed the patch and backported it. That's about all I can do now. I
suggest to close this and open new tickets if needed.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:11&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by veroandreo):

I have tested both in trunk r69822 and 72 release branch r69821 and the
issue prevails. Steps to reproduce are:
1. call g.gui.animation from terminal
2. add new animation
3. add stvds -> ok -> ok (animation works fine)
4. go to export icon
5. set a file type and name
6. go to decorations tab
7. add text
8. click export from there... No way, it does not respond. It is frozen.
The only remaining option is to close.

If you try to export directly, without touching the decoration tab, it
works fine. However you don't get any decoration.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:12&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by annakrat):

I understood the patch was working for Markus. You have both Fedora,
right?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:13&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by neteler):

Replying to [comment:13 annakrat]:
> I understood the patch was working for Markus.

I followed the procedure of Vero: I can still switch between "Format" und
"Decorations" tab but both the "Cancel" and "Export" buttons are like
disabled.

In the terminal there is many times:
{{{
(g.gui.animation:6695): Gtk-CRITICAL **: gtk_box_gadget_distribute:
assertion 'size >= 0' failed in GtkNotebook
}}}

> You have both Fedora, right?

Yes.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:14&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by neteler):

Just to clarify: (for me) g.gui.animation is not freezing, I think the
ticket's title is a bit misleading. "Simply" the buttons get somehow
disconnected, i.e. deactivated in the decorations dialog while the tabs
etc remain working.

Closing the decorations dialog with the upper right X brings me back to
the main window of the module which remains working (except for this
decorations dialog.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:15&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.2.0
Component: wxGUI | Version: svn-trunk
Resolution: | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------

Comment (by veroandreo):

Replying to [comment:15 neteler]:
> Just to clarify: (for me) g.gui.animation is not freezing, I think the
ticket's title is a bit misleading. "Simply" the buttons get somehow
disconnected, i.e. deactivated in the decorations dialog while the tabs
etc remain working.
>
> Closing the decorations dialog with the upper right X brings me back to
the main window of the module which remains working (except for this
decorations dialog.

Yes, the same for me... Sorry if the tittle is missleading, did not find
the proper words at time :frowning:

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:16&gt;
GRASS GIS <https://grass.osgeo.org>

#3153: g.gui.animation freezes when trying to add decorations
--------------------------+-----------------------------
  Reporter: veroandreo | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.2.4
Component: wxGUI | Version: svn-trunk
Resolution: fixed | Keywords: g.gui.animation
       CPU: Unspecified | Platform: Linux
--------------------------+-----------------------------
Changes (by veroandreo):

* status: new => closed
* resolution: => fixed

Comment:

I can't reproduce the reported bahavior any longer, closing

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3153#comment:22&gt;
GRASS GIS <https://grass.osgeo.org>