possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by fmw42 »

IM 6.7.1.0 Q16 Mac OSX Tiger. X11 1.1.3 - XFree86 4.4.0

I am unable to get show: to function. Seems like display works fine, but not show:

This works fine
display rose:

This displays nothing
convert rose: show:

Am I doing something wrong? Can anyone verify this? Is this just a problem on my Mac OSX tiger system?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by anthony »

Both are working fine for me.

show; is actually a 'hidden' line in the delegates.xml file (along with win:)
You may like to try the display command it uses manually.

More than likely it is the -window-group option that is at fault, as I think that may be X window specific. I myself do not understand what that display option is use for exactly.


Note I would look at IM examples, and delegates for more information
http://www.imagemagick.org/Usage/files/#delegate_spawn

Also look at the special "ephemeral:" coder which is also used...
http://www.imagemagick.org/Usage/files/#ephemeral
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by fmw42 »

I don't see anything in the delegates.xml file for show:

Anything else I can check. Perhaps I accidentally make an edit or something to alias show: to nothing? Is there some way to check?

show: seemed to work a few releases ago for me -- it is just recently that it stopped working?

Any way I can reset my X11 without reinstalling? Might it help to re-install IM?


display works just fine?

any way to reset the ephemeral:

how do I check -windows-group?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by anthony »

Code: Select all

grep '"show"' /etc/ImageMagick/delegates.xml
<delegate decode="png" encode="show" spawn="True" command=""display" -delay 0 -window-group %[group] -title "%l " "ephemeral:%i""/>
Which means send png files to the command,
spawn="True" means background the command when input file disappears
and the command is...
display -delay 0 -window-group {group} -title {image_label} ephemeral:{input_file}
I do not know what group means.

Actually I am suprised it is 'png' as that is only single images. I would have thought it should be miff!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by fmw42 »

This is what I get:

grep '"show"' /usr/local/etc/ImageMagick/delegates.xml
<delegate decode="png" encode="show" spawn="True" command=""/usr/local/bin/display" -delay 0 -window-group %[group] -title "%l " "ephemeral:%i""/>

find /usr | grep "display"
...
/usr/local/bin/display
...

I know this was working a few releases ago. Something has changed. I guess I will have to back down my release and confirm when it changed or if it is my system in some way.

I edit this to replace png with gif, or miff, or tif in order to test if it has something to do with some change to png, but still cannot get it to work.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by anthony »

try modifing the delegates file and remove the -window-group line. Basically play and see what you get!

Well curious I decided to 'play' myself...

For example I added this "show:" equivalent called "display:" to my personal delegates file (with shell verbose debugging)

Code: Select all

  <delegate decode="png" encode="display" spawn="True" command="sh -xv -c '"display" -delay 0 -title "%l" -window-group %[group] "ephemeral:%i"'"/>
now when I do

Code: Select all

  convert rose: display:
I get feedback from the shell to see what it is executing, but no display window appears for me!

Code: Select all

"display" -delay 0 -title "" -window-group 0x0 "ephemeral:/tmp/magick-fXSDV4BX"
+ display -delay 0 -title '' -window-group 0x0 ephemeral:/tmp/magick-fXSDV4BX
the first is what the shell read (-v option), the second what it executed (-x option)

But why nothing now appears on my display is a puzzle! It was executed, without error!

Removing all options for my "display:" delgate (equivalent to show:) including the spawn="True" works, though IM doesn't exit until the display command exits, so that is not much fun!

Code: Select all

  <delegate decode="png" encode="display" command="sh -xv -c '"display" "%i"'"/>

Code: Select all

convert rose: display:
"display" "/tmp/magick-JuMAwoEf"
+ display /tmp/magick-JuMAwoEf
^C
Re-adding the 'spawn="True"' also works, and the IM command will now exit and cleans up the tempoary file. BUT IM shouldn't exit as the 'spawn' is incomplete. Basically it should be waiting for the input file to be deleted, but as their was no ephemeral: it never will be deleted!

Something is NOT right and it may be a timing problem that causes the fault.
that is IM exits and cleans up the temp file, before the forked display command gets a chance to read it!

This is a BUG!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by fmw42 »

This does not seem to be fixed in IM 6.7.1.1 Q16 Mac OSX Tiger. See Anthony's comments just above where he believes this is a bug.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by magick »

How can we reproduce the problem? We tried
  • convert rose: show:
and it worked as expected (rose showed up on the desktop).
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by fmw42 »

magick wrote:How can we reproduce the problem? We tried
  • convert rose: show:
and it worked as expected (rose showed up on the desktop).
Curious? Did you try on your Mac?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by magick »

By default ImageMagick utilizes the display program. Does the display program work on your Mac:
  • display
If so, the show delegate should work. We'll try on our Mac this evening to confirm.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by fmw42 »

magick wrote:By default ImageMagick utilizes the display program. Does the display program work on your Mac:
  • display
If so, the show delegate should work. We'll try on our Mac this evening to confirm.

Display works fine as:

display rose:


Show does nothing but return to the next prompt with no image displayed.

convert rose: show:

no picture display and the terminal returns immediately to the next prompt.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by anthony »

The problem seems to have been a race condition.

If the 'spawned' delegate is slow in reading its image. the main IM process will go though its exit and 'delete' the input image. The result is no "display" window popup, not even an error!

What is supposed to happen with 'spawn=true' delegates is that the main IM process waits for the input image to disappear BEFORE it continues. That is it waits for the forked process to indicate that it has read the input image, typically using a "ephemeral:" codec.


Hmm tests of the latest version of IM seems to indicate that the problem no longer exists!
IM is again waiting for the spawned delegate to actually delete its input image, before continuing.


FYI...

This is a "display" delegate that does in shell, what IM should be doing when 'spawn=true' is used in a spawned delegate.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<delegatemap>
  <delegate decode="png" encode="display" command=""display" "ephemeral:%i" & while [ -f "%i" ]; do usleep 100; done"/>
</delegatemap>
and run it with...

Code: Select all

  convert rose: display:
This is similar to "show" except the shell script command performs the background spawn correctly, without using IM spawn delegate option.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by fmw42 »

Anthony:

I tried your suggestion above and edited my delegates.xml file. But when I ran the command to display: it worked but I got an error:


convert rose: display:

Code: Select all

sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
sh: line 1: usleep: command not found
convert: delegate failed `"display" "ephemeral:%i" & while [ -f "%i" ]; do usleep 100; done' @ error/delegate.c/InvokeDelegate/1058.
Interesting though, I do have man usleep.

Code: Select all

NAME
     usleep -- suspend thread execution for an interval measured in microsec-
     onds

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <unistd.h>

     int
     usleep(useconds_t microseconds);

DESCRIPTION
     The usleep() function suspends execution of the calling thread until
     either microseconds microseconds have elapsed or a signal is delivered to
     the thread and its action is to invoke a signal-catching function or to
     terminate the thread or process.  The actual time slept may be longer,
     due to system latencies and possible limitations in the timer resolution
     of the hardware.

    This function is implemented using nanosleep(2) by pausing for
     microseconds microseconds or until a signal occurs.  Consequently, in
     this implementation, sleeping has no effect on the state of process
     timers, and there is no special handling for SIGALRM.

RETURN VALUES
     The usleep() function returns the value 0 if successful; otherwise the
     value -1 is returned and the global variable errno is set to indicate the
     error.

ERRORS
     The usleep() function will fail if:

     [EINTR]            A signal was delivered to the process and its action
                        was to invoke a signal-catching function.

SEE ALSO
     nanosleep(2), sleep(3)

HISTORY
     The usleep() function appeared in 4.3BSD.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by anthony »

that usleep is a library function (man page section 3) not a command. Probably another standard GNU command installed on Linux but not MacOSX.

You can substitute sleep 1 but that is a full second sleep, where usleep 100 is a 1/10 second sleep.

The display: delegate is a stop gap measure, until we can get the show: function and spawning delegate working properly.

The thinking behind the 'race condition for delegate input file deletion' seems to be the case, but then I tried creating a "slow_display" script. EG:

Code: Select all

#!/bin/sh
echo "sleeping"
sleep 1
echo "running"
display "$@"
echo "finished" 
I think created a spawning delegate called "slow", by copying the "show" delegate from the system "delegate.xml" file and replacing the "display" display with "slow_display" command.

Code: Select all

  <delegate decode="miff" encode="slow" spawn="True" command=""slow_display" -delay 0 -window-group %[group] -title "%l " "ephemeral:%i""/>
When I tried it with...

Code: Select all

convert rose: slow:
It works flawlessly. IM did not actually 'exit' until after the real 'display' command ran ("running" was printed after a short pause) from the script, and it read its "ephemeral:" codec to delete the input file.

EG: time wise. Run command, "sleeping" "running" then the "convert" command finished with the display window appear almost at that same moment. indicating the delegate did not 'proceed' until that point was reached. The "finish is not printed until I manually close

This makes me think that my version of IM (from SVN) is fixed.

Please try this and see what happens in MacOSX, and in what order!


Also previously the "decode=" format in teh "show" delegate was "png" where it is now "miff" (thus allowing multiple image displays). Which indicates to me it was recentally 'fixed'. Can you see if your "show" delegate is decode="miff" or decode="png".
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug show: in IM 6.7.1.0 Q16 Mac OSX

Post by fmw42 »

I changed the show: delegate from miff to png and still it does not work.

I created your slow_display script and added your slow delegate and ran displayed but I got some messages and when I closed the window, I had to force an exit for it to return a prompt and finish



convert rose: slow:
sleeping
running
freds-mac-mini:~ fred$ sleeping
-bash: sleeping: command not found
freds-mac-mini:~ fred$ running
-bash: running: command not found
freds-mac-mini:~ fred$ finished
Post Reply