-
-
Notifications
You must be signed in to change notification settings - Fork 354
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] Saving animated gif hangs indefinitely #3664
Comments
Can you try |
The output with
|
This is the bug that we observe in JuliaPlots/PlotDocs.jl#248. @BeastyBlacksmith it seems that it's not a |
@chris-revell could you please try: bug.jl using Plots
@userplot CirclePlot
@recipe function f(cp::CirclePlot)
x, y, i = cp.args
n = length(x)
inds = circshift(1:n, 1 - i)
linewidth --> range(0, 10, length=n)
seriesalpha --> range(0, 1, length=n)
aspect_ratio --> 1
label --> false
x[inds], y[inds]
end
main() = begin
n = 150
t = range(0, 2π, length=n)
x = sin.(t)
y = cos.(t)
anim = @animate for i ∈ 1:n
circleplot(x, y, i)
end
println("marker1")
gif(anim, "anim_fps15.gif", fps=15)
println("marker2")
return
end
main() , and tell if that hangs or not ? |
This does indeed seem to hang indefinitely. "marker1" is printed, but "marker2" is not. |
Odd, I cannot reproduce, the example does not hang on my laptop. Could you please show the output of: ] status |
Strangely, I have 2 machines here, and am getting the same behaviour on both. The function seems to reach line 96 in animation.jl and then go no further. Here is the output you requested. Thanks for looking into this.
|
Thanks for helping here, if we can kill JuliaPlots/PlotDocs.jl#248 that'd be great 😉 ! Ha, I'm missing FFMPEG here, please try: ] st --manifest |
Quite a long output for this one:
|
Ok, we're on the same page here. Now, please re-run the example, adding |
Still seems to hang unfortunately. |
Killing the function (which only works after manually quitting the gksqt app that appears in the dock) produces the same stacktrace as in the original post above, emphasising line 96 in animation.jl and then FFMPEG. |
Ha great, I could not obtain a stacktrace on the CI. This one Line 96 in a39582c
|
Yes, exactly |
Stacktrace copied here again for reference: ERROR: InterruptException:
Stacktrace:
[1] poptask(W::Base.InvasiveLinkedListSynchronized{Task})
@ Base ./task.jl:760
[2] wait
@ ./task.jl:768 [inlined]
[3] wait(c::Base.GenericCondition{Base.Threads.SpinLock})
@ Base ./condition.jl:106
[4] wait(x::Base.Process)
@ Base ./process.jl:621
[5] success
@ ./process.jl:483 [inlined]
[6] run(::Cmd; wait::Bool)
@ Base ./process.jl:440
[7] run
@ ./process.jl:438 [inlined]
[8] (::FFMPEG.var"#4#6"{Cmd})(command_path::String)
@ FFMPEG ~/.julia/packages/FFMPEG/OUpap/src/FFMPEG.jl:112
[9] (::JLLWrappers.var"#2#3"{FFMPEG.var"#4#6"{Cmd}, String})()
@ JLLWrappers ~/.julia/packages/JLLWrappers/bkwIo/src/runtime.jl:49
[10] withenv(::JLLWrappers.var"#2#3"{FFMPEG.var"#4#6"{Cmd}, String}, ::Pair{String, String}, ::Vararg{Pair{String, String}, N} where N)
@ Base ./env.jl:161
[11] withenv_executable_wrapper(f::Function, executable_path::String, PATH::String, LIBPATH::String, adjust_PATH::Bool, adjust_LIBPATH::Bool)
@ JLLWrappers ~/.julia/packages/JLLWrappers/bkwIo/src/runtime.jl:48
[12] #invokelatest#2
@ ./essentials.jl:708 [inlined]
[13] invokelatest
@ ./essentials.jl:706 [inlined]
[14] #ffmpeg#7
@ ~/.julia/packages/JLLWrappers/bkwIo/src/products/executable_generators.jl:7 [inlined]
[15] ffmpeg
@ ~/.julia/packages/JLLWrappers/bkwIo/src/products/executable_generators.jl:7 [inlined]
[16] #exe#2
@ ~/.julia/packages/FFMPEG/OUpap/src/FFMPEG.jl:111 [inlined]
[17] ffmpeg_exe
@ ~/.julia/packages/FFMPEG/OUpap/src/FFMPEG.jl:123 [inlined]
[18] buildanimation(anim::Animation, fn::String, is_animated_gif::Bool; fps::Int64, loop::Int64, variable_palette::Bool, verbose::Bool, show_msg::Bool)
@ Plots ~/.julia/packages/Plots/OchXa/src/animation.jl:96
[19] #gif#249
@ ~/.julia/packages/Plots/OchXa/src/animation.jl:64 [inlined]
[20] main()
@ Main ./REPL[6]:11
[21] top-level scope
@ REPL[7]:1 |
Ok, and running again with FFMPEG verbose please, so that we are on a reproducible example ? |
Output with
Still hangs at this point. |
I'm wondering if the images at We note that is hangs on the first frame ... |
You can make FFMPEG even more verbose with |
|
Where should these be used? |
Always as keyword argument to |
Output with
|
So FFMPEG just hangs at the end after it finishes successfully? 🤷 |
Is |
It also doesn't actually save a file. |
It's there and I can successfully open it in Preview. |
I'm confused
These two statements look inconsistent. |
Sorry, I mean it doesn't save an animated gif file as intended by the function as a whole. |
I tried the following example: using Plots
using FFMPEG
anim = Animation();
for i = 1:1:5
p = Plots.plot(rand(10,10));
frame(anim, p);
end
gif(anim, "test.gif", fps=15, verbose=true);
It hangs as well. But I got it worked with the following steps, when it hangs:
1. force kill the gksqt
2. break the code running with ctrl + c
3. rerun "gif(anim, "test.gif", fps=15, verbose=true);"
Then it worked. |
This ran to completion without hanging for me. I did not set |
Ok, thank you, so this workaround seems reasonable for now:
@dapu can you try and report if this workaround works for you ? |
Just to add another spanner in the works, this does work when I run |
And by adding |
Nope, it hangs. |
It worked when I opened the REPL with I think I might just find a different visualisation technique... |
Try with |
I'm extremely confused why setting |
It hangs at first. Then I force killed the gksqt and hit the "ctrl + c" and it worked... |
I have the strong feeling the entire @chris-revell do this: ENV["JULIA_GR_PROVIDER"] = "GR"
using Pkg; Pkg.build("Plots") restart Julia and try again. |
I agree, feels like running in circles. |
This workaround works for me. |
This worked for me too |
That's it then, I guess? 🙂 |
I've tried #3664 (comment) in the CI, but unfortunately it does not solve JuliaPlots/PlotDocs.jl#248. |
But that's running on Linux? So maybe it's a completely different issue? |
It's hard to think it's not related: also animations, also hangs, and this used to build fine a few days ago. |
Did you try an older version of |
This is something I haven't tried yet, good idea. EDIT:
|
I can't reproduce it on macOS. Does your example work with:
using Plots
anim = Animation();
for i = 1:1:5
p = Plots.plot(rand(10,10));
frame(anim, p);
end
gif(anim, "test.gif", fps=15, verbose=true); |
The problem was only with the JLL, the default setup, is that what you tried? I suggested above to use GR provider as workaround |
Yes, I tried with the JLL. But would be interesting to see what happens if BTW: It's a pity that videos in |
I could reproduce the issue on M1 with Rosetta using the (probably not minimal) code shown above that I'm going to copy here for reference: using Plots
@userplot CirclePlot
@recipe function f(cp::CirclePlot)
x, y, i = cp.args
n = length(x)
inds = circshift(1:n, 1 - i)
linewidth --> range(0, 10, length=n)
seriesalpha --> range(0, 1, length=n)
aspect_ratio --> 1
label --> false
x[inds], y[inds]
end
main() = begin
n = 150
t = range(0, 2π, length=n)
x = sin.(t)
y = cos.(t)
anim = @animate for i ∈ 1:n
circleplot(x, y, i)
end
println("marker1")
gif(anim, "anim_fps15.gif", fps=15)
println("marker2")
return
end
main() |
Yes , the problem is related to |
Unfortunately, I can't reproduce this locally on Linux, this bug occurs on the CI (linux) for building the docs or on MacOS as the OP.
After further investigation, the problem seems triggered by
This is the failing example from the docs that hangs the docs build on CI.
I forgot about |
Details
Backends
This bug occurs on ( insert
x
below )Versions
Plots.jl version:
v1.19.3
Backend version (
]st -m <backend(s)>
):GR v0.58.0
Output of
versioninfo()
:Environment:
JULIA_NUM_THREADS = 4
I have written a visualisation routine in my program that uses a loop of the following form to create an animated gif of the results from a previous call of DifferentialEquations.jl
This loop successfully reaches
println("marker1")
but then hangs indefinitely on thegif()
call and never reachesprintln("marker2")
. Killing the program produces the following output:Reinstalling Julia with the latest binaries has made no difference.
The text was updated successfully, but these errors were encountered: