-
-
Notifications
You must be signed in to change notification settings - Fork 344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Display commands for d.mon
can take a long time *unexpectedly* to update the cmd
file when first run.
#3481
Comments
d.*
for d.mon wx*
can take a long time *unexpectedly* to update the cmd
file when first run.d.*
for d.mon wx*
can take a long time **unexpectedly** to update the cmd
file when first run.
d.*
for d.mon wx*
can take a long time **unexpectedly** to update the cmd
file when first run.d.*
for d.mon wx*
can take a long time *unexpectedly* to update the cmd
file when first run.
Or something like this... In if (**running in a tty OR not in GUI**) { /* Or we still need to check GRASS_REGION
in case we use non-interactive monitors. */
D_save_command(G_recreate_command());
D_close_driver();
return 1; /* it would be easier to just kill the process here, so we don't have to change anything
in display modules, but I'm not sure if that would be a better design */
} and in each display module: /* Setup driver and check important information */
if (D_open_driver() == 1) exit(EXIT_SUCCESS); |
d.*
for d.mon wx*
can take a long time *unexpectedly* to update the cmd
file when first run.d.rast.arrow
for d.mon wx*
can take a long time *unexpectedly* to update the cmd
file when first run.
OK, |
d.rast.arrow
for d.mon wx*
can take a long time *unexpectedly* to update the cmd
file when first run.d.mon
can take a long time *unexpectedly* to update the cmd
file when first run.
I did more testing. Without any changes to display modules, changing this: Lines 148 to 155 in b45319c
to if (p && G_strcasecmp(drv->name, p) != 0)
G_warning(_("Unknown display driver <%s>"), p);
G_verbose_message(_("Using display driver <%s>..."), drv->name);
LIB_init(drv);
init();
/* don't run display commands if GRASS_REGION (display extent) is not defined;
rendering will be done by the display driver */
if (!getenv("GRASS_REGION")) {
D_close_driver();
exit(0);
} worked. |
#3482 now uses a less invasive approach by returning |
I can confirm the issue, but the solution with Additionally, I actually tested the most bare bones way of rendering and that does not work with the new code (your two relevant PRs combined). The following takes ages with the current code, but with the proposed code, it does not render anything: export GRASS_RENDER_IMMEDIATE=cairo
export GRASS_RENDER_FILE_READ=TRUE
g.region rows=50 cols=50
rm map.png
d.rast nidp
d.rast.arrow -a drain_tx type=drainage
echo $? # 0 reported, but map.png contains only nidp I must say I don't understand how GRASS_REGION fixes that since g.region does not fix it for me here. Are there two issues? Double rendering going on or double init and the region not being respected? Is that the case? |
The I think you meant: export GRASS_RENDER_IMMEDIATE=cairo
export GRASS_RENDER_FILE_READ=TRUE
g.region rows=50 cols=50
rm map.png
d.rast nidp
d.rast.arrow drain_tx type=drainage which worked for me with 2fa11a2. |
I can confirm that with the latest change the basic ("immediate") rendering works again. Still, does the rendering actually happen twice? If yes, #3482 seems like fixing this double rendering issue using an implementation detail of the monitor-driven rendering somewhere deep in the monitor system, namely usage of GRASS_REGION. If user defines GRASS_REGION in the terminal, the GRASS_REGION-based test will pass and the situation is the same as what these PRs are trying to address. Is there a different way to tell that a d-command is being used as an interface in d.mon monitors rather than being used for actual rendering of data to a file? Or we say GRASS_REGION is the way and ignore the edge cases? |
Without any of my related PRs,
With my related PRs
If the return value of
Please try this. Defining export GRASS_REGION="proj: 99; zone: 0; north: 842288.7298103943; south: 842056.1497003906; east: -297381.45183609176; west: -297756.32556617697; cols: 1420; rows: 881; e-w resol: 0.2639955846; n-s resol: 0.2639955846; top: 1.000000000000000; bottom: 0.000000000000000; cols3: 44251; rows3: 41262; depths: 1; e-w resol3: 30; n-s resol3: 30; t-b resol: 1;"
export GRASS_RENDER_IMMEDIATE=cairo
export GRASS_RENDER_FILE_READ=TRUE
rm map.png
d.rast nidp
d.rast.arrow -a drain_tx type=drainage ![]() I also tested cat<<EOT>cmd.py
#!/usr/bin/env python3
import os
import sys
from grass.script import core as grass
from grass.script import task as gtask
os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"
os.environ["GRASS_RENDER_FILE_READ"] = "TRUE"
cmd = gtask.cmdstring_to_tuple(sys.argv[1])
grass.run_command(cmd[0], **cmd[1])
EOT
export GRASS_RENDER_COMMAND=cmd.py
rm -f map.png
g.region rows=50 cols=50
d.rast nidp
d.rast.arrow drain_tx type=drainage
cat<<EOT>cmd.py
#!/usr/bin/env python3
import os
import sys
from grass.script import core as grass
from grass.script import task as gtask
os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"
os.environ["GRASS_RENDER_FILE_READ"] = "TRUE"
cmd = gtask.cmdstring_to_tuple(sys.argv[1])
grass.run_command(cmd[0], **cmd[1])
EOT
export GRASS_RENDER_COMMAND=cmd.py
export GRASS_REGION="proj: 99; zone: 0; north: 842288.7298103943; south: 842056.1497003906; east: -297381.45183609176; west: -297756.32556617697; cols: 1420; rows: 881; e-w resol: 0.2639955846; n-s resol: 0.2639955846; top: 1.000000000000000; bottom: 0.000000000000000; cols3: 44251; rows3: 41262; depths: 1; e-w resol3: 30; n-s resol3: 30; t-b resol: 1;"
rm -f map.png
g.region rast=nidp
d.rast nidp
d.rast.arrow -a drain_tx type=drainage Initially, I thought we can simply
I think checking It would be convenient to have IPC (we used to have one many many years ago for UN*X) so the display library can communicate with the GUI, but now we have non-GUI display drivers and immediate rendering. |
I would be be very careful in limiting
That might have been the original motivation for adding that functionality, but it is compared to the
|
Describe the bug
When we run a display command (
d.*
) from the terminal to add a layer to awx*
monitor, it runs twice:GRASS_REGION
(display extent): This process adds a new command line to thecmd
file. If the command takes a long time to finish for the entire raster region, we have to wait even if the display extent is very small.GRASS_REGION
: The monitor runs the above command line saved in thecmd
file, but this time with the current display extent. The same command can run quickly if the display extent is very small. Ultimately, we will only see this result.To Reproduce
Steps to reproduce the behavior:
See it takes long even though the display extent is very small
Expected behavior
Any display commands should always honor the current display extent.
System description (please complete the following information):
Additional context
GRASS_REGION
is internal to the monitor and the terminal doesn't have access to it. Even ifGRASS_REGION
was exposed to the terminal, display commands would still run twice.I changed
grass/display/d.rast.arrow/main.c
Lines 222 to 223 in b45319c
to
and it worked. Basically,
d.rast.arrow
just adds a new command line to thecmd
file and exits. Then, it'll be executed by the monitor for actual rendering. This solution is not very elegant and takes the module developer's effort.Maybe, we add to
D_open_driver()
:and in each display module:
if rendering for the entire computational region can be expensive.
Still, I'm not 100% sure that
GRASS_REGION
must be required to render anything on a display. For example, render this entire raster on a PNG. I think we need a solution.Created #3482.
The text was updated successfully, but these errors were encountered: