mbaz / Gaston.jl

A julia front-end for gnuplot.
MIT License
148 stars 30 forks source link

Test failed on Windows 10 #136

Closed dact221 closed 4 years ago

dact221 commented 4 years ago

Hi

I installed gnuplot on Windows 10 and Gaston.jl on Julia 1.4.2. When I run the tests, one of the 2-D plots fails:

Test Summary:           | Pass  Total
Figure and set commands |   14     14
2-D plots: Test Failed at C:\Users\casas\.julia\packages\Gaston\kPsiM\test\runtests.jl:275
  Expression: begin
        set(reset = true)
        s = (MIME"image/svg+xml")()
        p = plot(1:10)
        a = repr(s, p)
        a[end - 7:end - 2] == "</svg>"
    end == true
   Evaluated: false == true
Stacktrace:
 [1] top-level scope at C:\Users\casas\.julia\packages\Gaston\kPsiM\test\runtests.jl:275
 [2] top-level scope at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Test\src\Test.jl:1113
 [3] top-level scope at C:\Users\casas\.julia\packages\Gaston\kPsiM\test\runtests.jl:62
Test Summary: | Pass  Fail  Broken  Total
2-D plots     |   42     1       3     46
ERROR: LoadError: Some tests did not pass: 42 passed, 1 failed, 0 errored, 3 broken.
in expression starting at C:\Users\casas\.julia\packages\Gaston\kPsiM\test\runtests.jl:61
ERROR: Package Gaston errored during testing

I tried to replicate the test evaluating line by line in the REPL, and I think I found the problem:

repr(s, p) ends with

\r\n</svg>\r\n\r\n

so a[end - 7:end - 2] is svg>\r\n instead of the expected </svg>

I also installed gnuplot and Gaston.jl on WSL and it works flawlessly. repr(s, p) has \n instead of \r\n.

I think the \r\n end of line in Windows is responsible of even more problems such as error messages the second time I evaluate a function from Gaston.jl.

┌ Warning: Gnuplot returned an error message:
│
│ gnuplot> eset session
│          ^
│          line 0: invalid command
│
└ @ Gaston C:\Users\casas\.julia\packages\Gaston\kPsiM\src\gaston_llplot.jl:180
mbaz commented 4 years ago

@dact221 Thanks for the report.

Fixing the test case should be easy. The second error you describe puzzles me, since the problem seems to be a missing first character (it should be reset session).

Could you run this:

set(debug=true)
plot(1:10)

and post the results?

dact221 commented 4 years ago

Hi @mbaz

Warnings about missing characters appear after the second plot shows.

julia> using Gaston

julia> set(debug=true)

julia> plot(1:10) # first plot
⌈Gaston
| Entering display()
⌊
⌈Gaston in function gnuplot_send
| reset session
⌊
⌈Gaston in function gnuplot_send
| set term qt 1
⌊
⌈Gaston in function gnuplot_send
| plot 'C:\Users\casas\AppData\Local\Temp\jl_bVN0FuWkbH' i 0
⌊
⌈Gaston in function gnuplot_send
| reset session
⌊
⌈Gaston in function gnuplot_send
| set output
⌊
⌈Gaston in function gnuplot_send
| set print '-'
| print 'GastonDone'
⌊
┌ Warning: Gnuplot returned an error message:
│
│ Warning: slow font initializationqt_processTermEvent received a GE_fontprops event. This should not have happened
└ @ Gaston C:\Users\casas\.julia\packages\Gaston\kPsiM\src\gaston_llplot.jl:180

julia> plot(1:10)  # second plot
⌈Gaston
| Entering display()
⌊
⌈Gaston in function gnuplot_send
| reset session
⌊
⌈Gaston in function gnuplot_send
| set term qt 1
⌊
⌈Gaston in function gnuplot_send
| plot 'C:\Users\casas\AppData\Local\Temp\jl_aeUOZ6qMk5' i 0
⌊
⌈Gaston in function gnuplot_send
| reset session
⌊
⌈Gaston in function gnuplot_send
| set output
⌊
⌈Gaston in function gnuplot_send
| set print '-'
| print 'GastonDone'
⌊
┌ Warning: Gnuplot returned an error message:
│
│ gnuplot> eset session
│          ^
│          line 0: invalid command
│
└ @ Gaston C:\Users\casas\.julia\packages\Gaston\kPsiM\src\gaston_llplot.jl:180

julia> plot(1:10) # third plot
⌈Gaston
| Entering display()
⌊
⌈Gaston in function gnuplot_send
| reset session
⌊
⌈Gaston in function gnuplot_send
| set term qt 1
⌊
⌈Gaston in function gnuplot_send
| plot 'C:\Users\casas\AppData\Local\Temp\jl_mQA9oe90k0' i 0
⌊
⌈Gaston in function gnuplot_send
| reset session
⌊
⌈Gaston in function gnuplot_send
| set output
⌊
⌈Gaston in function gnuplot_send
| set print '-'
| print 'GastonDone'
⌊
┌ Warning: Gnuplot returned an error message:
│
│ gnuplot> onDone''
│          ^
│          line 0: invalid command
│
│
│ gnuplot> set
│             ^
│          line 0: unrecognized option - see 'help set'.
│
└ @ Gaston C:\Users\casas\.julia\packages\Gaston\kPsiM\src\gaston_llplot.jl:180
mbaz commented 4 years ago

Thanks!

This might be due to the difference in newline characters in Linux and Windows, as you suggest, but I'm really not sure. I'll need to borrow a Windows computer to debug this. If you find anything else, please let me know.

mbaz commented 4 years ago

@dact221 Diego, could you please test some changes? First, check out the testwindows branch:

(@v1.4) pkg> add Gaston#testwindows

Then, run the tests and try plotting again.

dact221 commented 4 years ago

Hi @mbaz

The same test fails:

2-D plots: Test Failed at C:\Users\casas\.julia\packages\Gaston\a9imi\test\runtests.jl:275
  Expression: begin
        set(reset = true)
        s = (MIME"image/svg+xml")()
        p = plot(1:10)
        a = repr(s, p)
        occursin("</svg>", a[end - 8:end])
    end == true
   Evaluated: false == true
Stacktrace:
 [1] top-level scope at C:\Users\casas\.julia\packages\Gaston\a9imi\test\runtests.jl:275
 [2] top-level scope at D:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.4\Test\src\Test.jl:1113
 [3] top-level scope at C:\Users\casas\.julia\packages\Gaston\a9imi\test\runtests.jl:62
Test Summary: | Pass  Fail  Broken  Total
2-D plots     |   42     1       3     46

I evaluated the test line by line and got this:

julia> a[end - 8:end]
"/svg>\r\n\r\n"

That's easy to solve I guess, but I still get warnings because of missing starting characters (sometimes it is more than one character). Also, warnings now appear after the first plot.

julia> using Gaston#testwindows

julia> plot(1:10)
┌ Warning: Gnuplot returned an error message:
│
│ gnuplot> set
│              ^
│          line 0: unrecognized option - see 'help set'.
│
│
│ gnuplot> utput
│          ^
│          line 0: invalid command
│
└ @ Gaston C:\Users\casas\.julia\packages\Gaston\a9imi\src\gaston_llplot.jl:180

julia> plot(1:10)

julia> plot(1:10)
┌ Warning: Gnuplot returned an error message:
│
│ gnuplot> eset session
│          ^
│          line 0: invalid command
│
│
│ gnuplot> ut
│          ^
│          line 0: invalid command
│
└ @ Gaston C:\Users\casas\.julia\packages\Gaston\a9imi\src\gaston_llplot.jl:180
mbaz commented 4 years ago

I'll need to debug this on Windows. It will take me a couple of days I guess. Thanks for running the tests, and for your patience!

mbaz commented 4 years ago

@dact221 I just ran some tests on a Windows 10 machine, and I can't reproduce the problem (except the one failing test; I will fix it). In other words, I can plot any number of times, and it works fine.

I'm at a loss about what could be causing the behavior you see.

Are you running the official 64-bit Julia binary?

What version of gnuplot? I have tested 5.2 patchlevel 7 with MinGW, and also this binary. This latter binary is much, much faster than the MinGW binary.

What is your Windows 10 version? I have 10.0.16299.1868.

dact221 commented 4 years ago

Hi @mbaz

I am running the official 64-bit Julia binary.

Initially, I was using 5.2 patchlevel 8. I installed patchlevel 7 and it shows the same warnings. Even the binary you suggest shows warnings.

My Windows 10 is Version 2004 OS Build 19041.329 (May 2020 Update).

I see your Windows 10 version is from 2017. Maybe Microsoft did some change in recent versions that breaks Gaston.

mbaz commented 4 years ago

@dact221 I kept running tests, and I eventually was able to reproduce the problem. I found this gem:

gnuplot> peset session
         ^ line 0: invalid command

The stream between Gaston and gnuplot is getting corrupted; this is not caused by newline characters. I'm 99% sure this is not a Gaston bug, but rather Julia's or Windows'. I'll dig a bit more and then I'll probably file a bug in Julia's tracker.

dact221 commented 4 years ago

I installed the same two versions of gnuplot you used in a PC with Win10 version 1909 OS Build 18362.900 (May 2019 Update), and it shows the same warnings.

I also asked a colleague to try Gaston in his PC with Win10 version 1909 OS Build 18363 (November 2019 Update).

mbaz commented 4 years ago

I'm seeing very weird behavior:

dact221 commented 4 years ago

I'm seeing very weird behavior:

  • Running plot(1:10) almost always works, except that if I quit the plot window (with 'q'), then the next plot(1:10) almost always fails.
  • If I use the keyboard when focused on the plot (for example, hit the up-arrow key a few times), then the next plot almost always fails.

That's very weird behavior indeed. But in recent Windows 10 versions it's worse; it almost always shows warnings.

I was planning to precompile a Julia program with Gaston using PackageCompiler.jl and distribute it between colleagues. For now the executable only works in Linux, but most of my colleagues (civil engineers) are Windows 10 users. I guess they will have to import the output from Julia into Excel and plot there until this issue is solved.

mbaz commented 4 years ago

Is using WSL a possible workaround?

dact221 commented 4 years ago

Is using WSL a possible workaround?

Yes, it is. Actually, my only Linux installation is a Debian 11 Testing on WSL 2. I use X410 as X server for Windows 10, so I can see the plot window.

gaaraujo commented 4 years ago

Hello, I have run the #testwindows branch with Windows 10.0.18363 Build 18363 and used this binary. I have a JuliaPro v. 1.4.0 installation. I am always able to see the plot but if I close the figure manually or using Gaston.closefigure() I get warnings from gnuplot after a few trials.

image

In case you are not able to see the image, I copied the output here:

julia> plot(1:10)
⌈Gaston
| Entering display()
⌊
⌈Gaston in function gnuplot_send
| reset session
⌊
⌈Gaston in function gnuplot_send
| set term qt 1
⌊
⌈Gaston in function gnuplot_send
| plot 'C:\Users\arauj\AppData\Local\Temp\jl_CRNIe5DyJC' i 0
⌊
⌈Gaston in function gnuplot_send
| reset session
⌊
⌈Gaston in function gnuplot_send
| set output
⌊
⌈Gaston in function gnuplot_send
| set print '-'
| print 'GastonDone'
⌊

julia> closefigure()
⌈Gaston in function gnuplot_send
| set term qt 1 close
⌊

julia> plot(1:10)
⌈Gaston
| Entering display()
⌊
⌈Gaston in function gnuplot_send
| reset session
⌊
⌈Gaston in function gnuplot_send
| set term qt 1
⌊
⌈Gaston in function gnuplot_send
| plot 'C:\Users\arauj\AppData\Local\Temp\jl_LFXDdZck0S' i 0
⌊
⌈Gaston in function gnuplot_send
| reset session
⌊
⌈Gaston in function gnuplot_send
| set output
⌊
⌈Gaston in function gnuplot_send
| set print '-'
| print 'GastonDone'
⌊
┌ Warning: Gnuplot returned an error message:
│
│ gnuplot> pet print '-'
│          ^
│          line 0: invalid command
│
└ @ Gaston C:\Users\arauj\.juliapro\JuliaPro_v1.4.0-1\packages\Gaston\a9imi\src\gaston_llplot.jl:180
mbaz commented 4 years ago

@gaaraujo Gustavo, you're seeing the same issue. I don't think it's a bug in Gaston, but I'm gathering as much data as I can on it to file a Julia issue.

In the meantime, the workaround is to use WSL.

gaaraujo commented 4 years ago

Hello again @mbaz Using the same gnuplot binary, Julia Installation and Windows version, I installed Gnuplot.jl As in Gaston.jl, the plot always renders. If I use @gp "q" and try to plot again, no warnings. But if I close the figure manually and try to plot again, I get the same warning as in Gaston. This makes me think that the bug is not related to Gaston directly, as you suggested.

julia> using Gnuplot
[ Info:   Gnuplot version: 5.2.0

julia> @gp 1:10
[ Info: Creating session default...
[ Info:   Gnuplot version: 5.2.0
GNUPLOT (default) -> wxt
GNUPLOT (default) -> 0 enhanced

julia> @gp "q"

julia> @gp 1:10
[ Info: Creating session default...
[ Info:   Gnuplot version: 5.2.0
GNUPLOT (default) -> wxt
GNUPLOT (default) -> 0 enhanced

julia> @gp "q"

julia> @gp 1:10
[ Info: Creating session default...
[ Info:   Gnuplot version: 5.2.0
GNUPLOT (default) -> wxt
GNUPLOT (default) -> 0 enhanced

julia> @gp 1:10
# I closed the figure manually here
julia> @gp 1:10

julia> GNUPLOT (default) -> gnuplot> r
julia> GNUPLOT (default) ->          ^
GNUPLOT (default) ->          line 22: invalid command
GNUPLOT (default) -> gnuplot> eset session
GNUPLOT (default) ->          ^
GNUPLOT (default) ->          line 22: invalid command
mbaz commented 4 years ago

@gaaraujo Thank you for testing this!

I have been running tests of Julia's streams support without finding any bugs. My next step was to try this with Gnuplot.jl, so you saved me some work.

Indeed, this looks like a bug in gnuplot (or at least a bad interaction with Windows streams). I'll look into filing a gnuplot bug report.

By the way, if I close the figure in Gaston manually (with closeall()), I also tend to get no errors. It's mostly when closing the figure manually with q that this happens.

mbaz commented 4 years ago

@dact221 @gaaraujo I just reproduced the problem from Python. The good news is that the problem is neither Gaston nor Julia. The bad news is that the problem is either gnuplot or windows -- and who knows how long those will take to get fixed.

I'd suggest using WSL for the time being.

dact221 commented 4 years ago

@mbaz Thanks for your interest in trying to solve this issue. So far it still allow us to generate the plot besides the warnings and the occasional strange behavior.

We will continue exploring the capabilities of Gaston.jl with PackageCompiler.jl

mbaz commented 4 years ago

Gnuplot issue filed here: https://sourceforge.net/p/gnuplot/bugs/2279/

mbaz commented 4 years ago

@dact221 @gaaraujo If you have a chance, can you try this:

I've been unable to reproduce the problem with this setup.

dact221 commented 4 years ago

Hi @mbaz

When I set the terminal to "windows", I am unable to reproduce the problem. I'm using gnuplot 5.2 patchlevel 8. I think that solves the issue.

Can you implement that terminal switch in Gaston.jl or have Windows users do it in their code?

mbaz commented 4 years ago

@dact221 I will set things up so that, in Windows, the default terminal is "windows" instead of "qt". I will also fix the failing test, and then I'll release v1.0.1. Should take me a couple of days.

dact221 commented 4 years ago

@dact221 I will set things up so that, in Windows, the default terminal is "windows" instead of "qt". I will also fix the failing test, and then I'll release v1.0.1. Should take me a couple of days.

@mbaz Thank you. I really appreciate your work.

@gaaraujo and I already compiled a Julia program with Gaston.jl (GMDApp) and provided it as a pre-release. When you release Gaston.jl v1.0.1, we'll release v1.0 of our program.

mbaz commented 4 years ago

Version 1.0.1 has been released.