It is currently Wed Nov 18, 2026 5:52 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 91 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 12:09 pm  (#31) 
Offline
Administrator
User avatar

Joined: Aug 10, 2012
Posts: 14276
Location: Native to NYC living in Arizona, Gimp 2.8 - 3.0, Win 11 PC.
GnuTux wrote:
All this script does is display the input slider/spinner (which is a predefined Script-Fu procedure) and then prints the results when you click OK. That's it. Whatever is happening is something internal to GIMP/Script-Fu.

It's possible that it doesn't affect Windows but I doubt that's the case. This is not the first time I've ran across these kinds of strange things and sometimes, it's just harder to confirm the weirdness is occurring across all OS's.

Here's another example of a bug that cannot be consistently reproduced in Windows and Linux, but it's there.

Strange... :?

_________________
Image
"A wise man learns more from a foolish question than a fool can learn from a wise answer"
Image


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 12:12 pm  (#32) 
Offline
GimpChat Member
User avatar

Joined: Nov 16, 2011
Posts: 5127
Location: Metro Vancouver, BC
Here's a variation of the test on Linux.
1. Spinner set directly to 0
Test Zero Warning
Value: 1.387778781e-16

2. Spinner advanced to 1.1 and then to 0
Test Zero Warning
Value: 0

The second result was consistent using other +1.0 values before running the test at 0. I've run this test using reset between #1 & #2 and only running test #2 on a new image.

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 12:28 pm  (#33) 
Offline
GimpChat Member
User avatar

Joined: Apr 07, 2010
Posts: 14182
Went back to windows again and ran 4 times with the spinner and 4 times with the slider.
Here are my results. The top window was with the spinner and the bottom with the slider.
Image

_________________
Image


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 12:34 pm  (#34) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5244
Location: Gimpville
Ok, thanks Molly. That confirms the bug is occurring in both Windows and Linux.

I created a little video that demonstrates how using the spinner to set to zero sometimes displays the correct value and sometimes doesn't.

www.youtube.com Video from : www.youtube.com

_________________
"If Microsoft ever does applications for Linux it means I've won." - Linus Torvalds


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 12:46 pm  (#35) 
Offline
GimpChat Member
User avatar

Joined: Nov 15, 2014
Posts: 878
I have run this several times. The first time I got a non-zero value with the spinner, zero with the slider. Second time I got non-zero value with the spinner, without restarting GIMP I set to a value with the spinner, then zeroed with the slider and got a non-zero value. Every subsequent attempt I have zero both ways. (I close and re-open GIMP between each test.)

This is with Ubuntu 14.04LTS and GIMP 2.8.

I shall leave the computer running and check later if you wish me to do further tests.

david.


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 12:55 pm  (#36) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5244
Location: Gimpville
@David - Thanks for testing. I'd say we have enough Linux tests to confirm that there is something wrong here.

@Odin - You're right. If I move the spinner up, then back down to zero, I get a zero result. I also noticed when moving the slider and the spinner up and down, then using the spinner to move to zero, I sometimes get a really outlandish result, like this:

Test Zero Warning
Value: 4.718447855e-15

_________________
"If Microsoft ever does applications for Linux it means I've won." - Linus Torvalds


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 1:29 pm  (#37) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
Looks like it is a GTK problem after all (as my first tests suggested, but later tests counter-suggested!)
I've now hacked a copy of the Script-Fu plugin to show the actual double float values returned from the GTK spinbutton.
Starting at 1.0 (indicated) and stepping down (in steps of 0.1), these are the values actually passed to the Script-Fu plugin:
1.00000000000000000000
0.90000000000000002220
0.80000000000000004441
0.70000000000000006661
0.60000000000000008882
0.50000000000000011102
0.40000000000000013323
0.30000000000000015543
0.20000000000000014988
0.10000000000000014433
0.00000000000000013878
-0.09999999999999986677
-0.19999999999999987232
-0.29999999999999987788
-0.39999999999999991118


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 1:46 pm  (#38) 
Offline
GimpChat Member
User avatar

Joined: Jan 31, 2015
Posts: 146
Linux 64-bit:

Image


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 2:01 pm  (#39) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
Things seem to work fine on 32-bit GNU/Linux; it is only on 64-bit GNU/Linux that the anomalous behavior was exhibited. I'd expect the same is true on Microsoft OSes, but have no way of testing.

The 'spin up' button on the spinner appears to be the culprit that actually introduces the "imprecision". That is to say, starting from a "precise" value, the 'spin down' button by itself never seems to result in the near-zero anomaly. There is no way to see that the imprecision has been introduced, other than by spinning it down to zero.

Explicit numeric entry, slider stepping, and slider dragging all result in a precise value being set -- after the value has been set using one of these methods, the near-zero anomaly will not occur by using the spin down button. It is only when a spin up button press is introduced into the flow that the possibility of the near-zero anomaly exists (even though it can only become apparent by following the spin up with a spin down).

I have looked at the Script-fu source code and see nothing amiss. It would be interesting to see the same testing performed with Python-fu. I suspect that this is a problem with GTK+ and that somewhere a float value is being read as a double (or a double is being read as a long double).

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 2:08 pm  (#40) 
Offline
GimpChat Member
User avatar

Joined: Dec 02, 2012
Posts: 203
Location: Cantabria, Spain
My results


Attachments:
test_zero.png
test_zero.png [ 115.44 KiB | Viewed 2972 times ]

_________________
Image



My Gimp rides on Antergos (Arch), Linux Mint, Debian and Fedora
Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 2:13 pm  (#41) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
saulgoode wrote:
The 'spin up' button on the spinner appears to be the culprit that actually introduces the "imprecision". That is to say, starting from a "precise" value, the 'spin down' button by itself never seems to result in the near-zero anomaly.


Beg to differ, Saul.
The list of values I posted above started at 1.0 (the preset value for the spinbutton) and stepped-down only. At no point did I press the up button. And I've just tried it again from Gimp restart - the anomaly does arise using only the down button.


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 2:15 pm  (#42) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
jontait2 wrote:
Starting at 1.0 (indicated) and stepping down (in steps of 0.1), these are the values actually passed to the Script-Fu plugin:
1.00000000000000000000
0.90000000000000002220
0.80000000000000004441
:
:
:

Interesting. I was unable to coerce the near-zero value when I tried spinning down from a precise value, but your test shows that it is possible. Perhaps I did not try it enough times.

:ninja

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 2:48 pm  (#43) 
Offline
GimpChat Member
User avatar

Joined: Nov 15, 2014
Posts: 878
After my entry above (No. 35) I shut down the computer, rebooted, open GIMP again and repeated the test several times. For some of them I closed and re-opened Gimp, for others I used the reset button. The result was always zero. I left the computer running for about 1 hour (GIMP closed), re-opened GIMP ran the test again and got a non-zero result. Numerous retries were all zero.

I am using 32 bit Ubuntu incidentally.

I do not know if this is of any help. However, if I can do anything useful, just ask.

david.

edit: I have used the "up" button to start with values of 0.5, 0.4, 0.3, 0.2, 0.1 and in each case decremented down in steps of 0.1. All results correct until I hit zero when the result is always 2.775557562e-17. I have also entered the start value of 0.5 using the keyboard and then decremented down with the same result.


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 3:21 pm  (#44) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Gnutux, just a curiosity:
did you try whether the result would show always 0 if in the gimp-message you place in front of the value the (inexact->exact) cast operator?

_________________
"Where am I ?"


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sat Apr 18, 2015 11:19 pm  (#45) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5244
Location: Gimpville
Good detective work, jon & saul. :hi5

I wonder if this has already been filed as a bug report?

@dinasset - Have you tried it? I checked it out in the console and it was expecting an integer.

I suppose a work around would be to round to the number of decimal places corresponding to the precision specified in SF-ADJUSTMENT.

(define (round-decimal places num)
  (let ((x (expt 10.0 places)))
    (/ (round (* x num)) x)))

_________________
"If Microsoft ever does applications for Linux it means I've won." - Linus Torvalds


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sun Apr 19, 2015 1:42 am  (#46) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
Sorry GnuTux,
I didn't try because on my PC result is displayed correctly, but you are perfectly right: that cast applies only to integers.

_________________
"Where am I ?"


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sun Apr 19, 2015 2:07 am  (#47) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14835
Location: roma, italy
GnuTux
I know it sounds strange, apparently, but I have another "silly" suggestion:
try to replace the gtk dll's of gimp release 2.8.14 with those on gimp 2.8.10
I recall my problem with document history, which was solved that way
("just to let other people curious on this aspect know the follow-on:
-made some other test
-discovered that it's the .dll related to gtk which causes this problem (it has been changed between 2.8.10 and 2.8.14)
-by overwriting the version of that .dll present on 2.8.14 with the one present in 2.8.10, the history is kept as expected.")

I say that because on my PC results are precisely 0.
Just a try should be simple (only keep aside the dll replaced for safety...)

_________________
"Where am I ?"


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sun Apr 19, 2015 2:29 am  (#48) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
dinasset wrote:
GnuTux
I know it sounds strange, apparently, but I have another "silly" suggestion:
try to replace the gtk dll's of gimp release 2.8.14 with those on gimp 2.8.10
I recall my problem with document history, which was solved that way
("just to let other people curious on this aspect know the follow-on:
-made some other test
-discovered that it's the .dll related to gtk which causes this problem (it has been changed between 2.8.10 and 2.8.14)
-by overwriting the version of that .dll present on 2.8.14 with the one present in 2.8.10, the history is kept as expected.")

I say that because on my PC results are precisely 0.
Just a try should be simple (only keep aside the dll replaced for safety...)


Not much point in doing this as I observe the same behaviour using GIMP 2.6.7


Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sun Apr 19, 2015 2:53 am  (#49) 
Offline
GimpChat Member
User avatar

Joined: Mar 01, 2014
Posts: 14252
Location: Spain, Aragón
GnuTux, here my two results. First I put the slider to 0; Then reset and set the slider to 0.


Attachments:
Slide to 0.JPG
Slide to 0.JPG [ 13.15 KiB | Viewed 2817 times ]
After resert and slider to 0.JPG
After resert and slider to 0.JPG [ 13.59 KiB | Viewed 2817 times ]

_________________
Image

Gimp 2.10.36 (samj) portable _ OS Windows 10 Home_ 64bits
Don’t be afraid to start over. It’s a new chance to rebuild what you want.
Top
 Post subject: Re: Need Assistance Testing Another Simple Script
PostPosted: Sun Apr 19, 2015 3:21 am  (#50) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
Yes, I don't think this line of enquiry is really going to get us very far.

It would seem that there is indeed a bug in GTK which can produce these anomalous results but I cannot see from the source code precisely where it's happening, so (unless this is already a known bug) to get a handle on the problem, somebody is going to have to hack and compile GTK from source. And I don't really want to do that right now!

But this is rather missing the point: even if we do mend GTK, or put a workaround for the problem into the GimpChat Script-Fu Extension plugin, that's still going to leave a problem for anybody using legacy versions or the standard Script-Fu Extension as supplied with Gimp.

We already know that Script-Fu input parameters may have to be sanitized before use - as we've seen on a number of occasions, even if the range for SF_ADJUSTMENT only allows integer values, if the slider is used, the value supplied to the script may be a full-precision float.

So I think, for the sake of robustness, we really need to extend and generalize the principle of "sanitizing" input values thus:
- float values can be used as supplied to the script;
- integer values must be sanitized by rounding or truncating;
- other numeric values (ie. numbers with a decimal fraction, but not float) must be sanitized by rounding or truncating to the nearest step-point.

I see GnuTux has already posted a (round-decimal ) function which is pretty much what I was going to suggest.


Top
Post new topic Reply to topic  [ 91 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group