JuliaImages / ImageView.jl

Interactive display of images and movies
MIT License
135 stars 34 forks source link

WARNINGS and Tk error when using view() with latest Julia v0.4.0 (OSX 10.9.5) #57

Closed maxruby closed 9 years ago

maxruby commented 9 years ago

After pulling julia-v0.4.0 master, rebuilding julia, doing Pkg.update(), I encountered the following with ImageView (OSX 10.9.5):

julia> using Color, FixedPointNumbers
julia> import Images, ImageView
julia> filename = joinpath(Pkg.dir("OpenCV"), "./test/images/lena.jpeg")
"/Users/maximilianosuster/.julia/OpenCV/./test/images/lena.jpeg"

julia> image = Images.imread(filename)  # load with Images.jl
Gray Images.Image with:
  data: 512x512 Array{Images.ColorTypes.Gray{FixedPointNumbers.UfixedBase{UInt8,8}},2}
  properties:
    imagedescription: <suppressed>
    spatialorder:  x y
    pixelspacing:  1 1

julia> ImageView.view(image)
WARNING: sizehint(A,n) is deprecated, use sizehint!(A,n) instead.
 in depwarn at ./deprecated.jl:40
WARNING: iceil(x) is deprecated, use ceil(Integer,x) instead.
 in depwarn at ./deprecated.jl:40
WARNING: ifloor(x) is deprecated, use floor(Integer,x) instead.
 in depwarn at ./deprecated.jl:40
WARNING: iceil(x) is deprecated, use ceil(Integer,x) instead.
 in depwarn at ./deprecated.jl:40
WARNING: ifloor(x) is deprecated, use floor(Integer,x) instead.
 in depwarn at ./deprecated.jl:40
WARNING: iround(x) is deprecated, use round(Integer,x) instead.
 in depwarn at ./deprecated.jl:40
(ImageCanvas,ImageSlice2d: zoom = Base.Graphics.BoundingBox(0.0,512.0,0.0,512.0))

julia> WARNING: ifloor(x) is deprecated, use floor(Integer,x) instead.
 in depwarn at ./deprecated.jl:40
WARNING: ifloor(x) is deprecated, use floor(Integer,x) instead.
 in depwarn at ./deprecated.jl:40
 . . .  

The WARNING goes on forever and the only way to stop it in the REPL is to use ctrl C.
The first time it actually reported a Tk error, but I did not see it the second time I tested.

timholy commented 9 years ago

The repeated warnings should have been fixed by https://github.com/JuliaLang/julia/pull/9291, if you have a sufficiently-modern 0.4.

But I need to fix these deprecation warnings within ImageView, because they also cause a major performance hit. I've not been looking at big images recently, so I haven't had much incentive.

BTW, you might also be interested in https://github.com/timholy/TestImages.jl. If you'd like to generalize it to allow reading directly into OpenCV.jl's format, that would be fine with me. The main tricky thing would be to avoid the penalty for loading both Images and OpenCV. Winston contains an example of how to configure an environment variable to determine which graphical backend (Tk or Gtk) gets loaded. We could also check isdefined(Main, :Images) and isdefined(Main, :OpenCV) if no environment variable is set.

timholy commented 9 years ago

Oh wait, you said your julia is completely up to date. But, let me guess: because of Cxx you are using LLVM-svn (or LLVM-3.5), and your backtraces are broken. (What does make test-backtrace give you?)

maxruby commented 9 years ago

I think my Julia 0.4-dev build from this morning should hopefully be modern enough :) Yes, I am using LLVM 3.5svn (according to Keno´s requirement). I will have a look at how Testimages.jl could be adapted when I find some time.

backtrace (very very very long process. . .) says

    JULIA test/backtrace
     * backtrace
    SUCCESS

Full trace is here.

Any suggestions?

timholy commented 9 years ago

That's for your whole build (you must have had something "stale" so it rebuilt julia for you). Here's a more useful test:

julia> @noinline function myfunction()
           backtrace()
       end
myfunction (generic function with 1 method)

julia> bt = myfunction()
18-element Array{Ptr{Void},1}:
 Ptr{Void} @0x00007f169b8a9c55
 Ptr{Void} @0x00007f169b8a9cb0
 Ptr{Void} @0x00007f169c88d850
 Ptr{Void} @0x00007f169c88d830
 Ptr{Void} @0x00007f169b85bec6
 Ptr{Void} @0x00007f169b8a32b8
 Ptr{Void} @0x00007f169b8a282f
 Ptr{Void} @0x00007f169b8a2621
 Ptr{Void} @0x00007f169b8a38ba
 Ptr{Void} @0x00007f169b8a1e08
 Ptr{Void} @0x00007f169b8b4477
 Ptr{Void} @0x00007f169b863d76
 Ptr{Void} @0x00007f169c888f2a
 Ptr{Void} @0x00007f169c888ad7
 Ptr{Void} @0x00007f169b85be3a
 Ptr{Void} @0x00007f169c88521d
 Ptr{Void} @0x00007f169b8a9851
 Ptr{Void} @0x0000000000000000

julia> for b in bt
           @show Profile.lookup(b)
       end
Profile.lookup(b) = Base.Profile.LineInfo("rec_backtrace","/home/tim/src/julia/usr/bin/../lib/libjulia.so",-1,true,139735075560533)
Profile.lookup(b) = Base.Profile.LineInfo("jl_backtrace_from_here","/home/tim/src/julia/usr/bin/../lib/libjulia.so",-1,true,139735075560624)
Profile.lookup(b) = Base.Profile.LineInfo("myfunction","none",2,false,139735092222032)
Profile.lookup(b) = Base.Profile.LineInfo("jlcall_myfunction_42513","",-1,true,139735092222000)
Profile.lookup(b) = Base.Profile.LineInfo("jl_apply_generic","/home/tim/src/julia/usr/bin/../lib/libjulia.so",-1,true,139735075241670)
Profile.lookup(b) = Base.Profile.LineInfo("???","???",139735075533496,true,139735075533496)
Profile.lookup(b) = Base.Profile.LineInfo("???","???",139735075530799,true,139735075530799)
Profile.lookup(b) = Base.Profile.LineInfo("???","???",139735075530273,true,139735075530273)
Profile.lookup(b) = Base.Profile.LineInfo("???","???",139735075535034,true,139735075535034)
Profile.lookup(b) = Base.Profile.LineInfo("???","???",139735075528200,true,139735075528200)
Profile.lookup(b) = Base.Profile.LineInfo("???","???",139735075603575,true,139735075603575)
Profile.lookup(b) = Base.Profile.LineInfo("jl_toplevel_eval_in","/home/tim/src/julia/usr/bin/../lib/libjulia.so",-1,true,139735075274102)
Profile.lookup(b) = Base.Profile.LineInfo("eval_user_input","REPL.jl",54,false,139735092203306)
Profile.lookup(b) = Base.Profile.LineInfo("jlcall_eval_user_input_42463","",-1,true,139735092202199)
Profile.lookup(b) = Base.Profile.LineInfo("jl_apply_generic","/home/tim/src/julia/usr/bin/../lib/libjulia.so",-1,true,139735075241530)
Profile.lookup(b) = Base.Profile.LineInfo("anonymous","task.jl",96,false,139735092187677)
Profile.lookup(b) = Base.Profile.LineInfo("???","???",139735075559505,true,139735075559505)
Profile.lookup(b) = Base.Profile.LineInfo("???","???",0,true,0)

Notice that I got useful file names and line numbers for many of these.

But I basically have a PR almost cued up that will fix this; just waiting on https://github.com/JuliaLang/julia/pull/9278#issuecomment-67312676. Or I'll do it myself, or you can submit a sizehint! PR to Compat and then I'll merge my queued-up ImageView PR.

maxruby commented 9 years ago

OK, I see that the trace is for the whole build (and that it rebuilt it again) but I don´t get your point about something being "stale". . . I simply took the the fresh master from github, and after updating the folder (including deps/llvm folders) with git pull, performed the standard build, which has worked perfectly before this update. . . My makefile is identical to the one we use for Cxx (which has also worked before).

Here is my output for the test you suggested:

julia> @noinline function myfunction()
                  backtrace()
              end
myfunction (generic function with 1 method)

julia> bt = myfunction()
1-element Array{Ptr{Void},1}:
 Ptr{Void} @0x000000010d140f6e

julia> for b in bt
                  @show Profile.lookup(b)
              end
Profile.lookup(b) = Base.Profile.LineInfo("rec_backtrace","/Users/maximilianosuster/julia-v0.4.0/src/task.c",623,true,4514385774)
maxruby commented 9 years ago

Not sure I get your point fully about the planned fixes.
The deprecation WARNINGS I see when using ImageView.view() include:

The biggest trouble for me right now seems to be the ifloor(x) WARNING, because it never stops once the window is open with ImageView.view(). Should I look into using Compat.jl to fix these warnings? I could not find anything specifically on iceil, iround, ifloor.

timholy commented 9 years ago

Easiest if I just show you. See #58. It will break ImageView on 0.3 currently because no one added sizehint! to Compat.jl.

timholy commented 9 years ago

See this PR in Compat for how I fixed iceil, iround, and ifloor: https://github.com/JuliaLang/Compat.jl/pull/20 and later improved by Simon Byrne: https://github.com/JuliaLang/Compat.jl/pull/22

maxruby commented 9 years ago

Thanks for sharing the examples. Got it, seems straightforward.

It seems that Compat.jl #25 asks to keep sizehint for v0.3. In our case, we want sizehint! added for v0.4 only. Let me know if I can help or if you will take care of this, since you already generated #58.

timholy commented 9 years ago

Sure, go ahead and make the addition to Compat.

timholy commented 9 years ago

You also should tag a new version of Compat. Let me know if you have questions about how to do that (it's no different than tagging one of your own packages, once your PR gets accepted).

maxruby commented 9 years ago

Thanks. I think I will manage since I have tagged my own package.

timholy commented 9 years ago

Looks like I forgot to hit "comment" on this, so it's out of order (it's about your backtraces):

All I meant was that most of that output you put in the gist was from building julia, and not the result from running the test. Only the last three lines were from running the test.

But that test definitely shows there's something broken about your backtraces. (It's not your fault; see https://github.com/JuliaLang/julia/issues/7910.) That's why you're seeing zillions of warnings, and I'm not.

maxruby commented 9 years ago

Got it. Thanks a lot for the explanation. I will be back today with the PR submission for Compat.jl. Its basically done but I want to make sure that it works for all 5 methods of sizehint!.

timholy commented 9 years ago

See https://github.com/JuliaLang/Compat.jl/pull/30