Skip to content

Example script measure_latency.jl fails #93

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

Open
JRice15 opened this issue Nov 23, 2021 · 2 comments
Open

Example script measure_latency.jl fails #93

JRice15 opened this issue Nov 23, 2021 · 2 comments

Comments

@JRice15
Copy link

JRice15 commented Nov 23, 2021

As a relative newcomer to Julia and this package, I thought I'd try out an example script. audiometer.jl works fine. measure_latency.jl does not.

I've narrowed the issue down to the write call on line 37. It seems that an exception is thrown here, but some combination of this package's problems with multi-threading (#81) and/or error suppression (#89) makes it error out silently at this spot (meaning, the script just exits, showing no output, but with an exit code of 1).

If I wrap the call like so:

try
    write(out_stream, signal)
catch e
    showerror(stdout, e, catch_backtrace())
end

I get this output:

MethodError: hereno method matching 
Matrix{Float32}(::Vector{Float32})
Closest candidates are:
  Array{T, N}(::AbstractArray{S, N}) where {T, N, S} at array.jl:540
  Matrix{T}(::LinearAlgebra.UpperHessenberg) where T at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/hessenberg.jl:68
  Matrix{T}(::LinearAlgebra.UpperTriangular) where T at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/triangular.jl:177
  ...
Stacktrace:
  [1] convert(#unused#::Type{Matrix{Float32}}, a::Vector{Float32})
    @ Base ./array.jl:532
  [2] cvt1
    @ ./essentials.jl:322 [inlined]
  [3] ntuple
    @ ./ntuple.jl:50 [inlined]
  [4] convert(#unused#::Type{Tuple{Matrix{Float32}, Int64, Int64}}, x::Tuple{Vector{Float32}, Int64, Int64})
    @ Base ./essentials.jl:323
  [5] put!(c::Channel{Tuple{Matrix{Float32}, Int64, Int64}}, v::Tuple{Vector{Float32}, Int64, Int64})
    @ Base ./channels.jl:315
  [6] exchange(::PortAudio.Messanger{Float32, PortAudio.SampledSignalsWriter, Tuple{Matrix{Float32}, Int64, Int64}, Int64}, ::Vector{Float32}, ::Vararg{Any, N} where N)
    @ PortAudio ~/.julia/packages/PortAudio/iJ74y/src/PortAudio.jl:1018
  [7] unsafe_write(sink::PortAudio.PortAudioSink{PortAudio.Messanger{Float32, PortAudio.SampledSignalsWriter, Tuple{Matrix{Float32}, Int64, Int64}, Int64}, PortAudio.Messanger{Float32, PortAudio.SampledSignalsReader, Tuple{Matrix{Float32}, Int64, Int64}, Int64}}, julia_buffer::Vector{Float32}, already::Int64, frame_count::Int64)
    @ PortAudio ~/.julia/packages/PortAudio/iJ74y/src/PortAudio.jl:1029
  [8] write
    @ ~/.julia/packages/SampledSignals/WU1nF/src/SampleStream.jl:156 [inlined]
  [9] write
    @ ~/.julia/packages/SampledSignals/WU1nF/src/SampleStream.jl:177 [inlined]
 [10] write
    @ ~/.julia/packages/SampledSignals/WU1nF/src/SampleStream.jl:176 [inlined]
 [11] write
    @ ~/.julia/packages/PortAudio/iJ74y/src/PortAudio.jl:918 [inlined]
 [12] macro expansion
    @ ~/Desktop/CS/julia/measure_latency.jl:43 [inlined]
 [13] (::var"#3#5"{Vector{Float32}, Base.Event, PortAudioStream{PortAudio.Messanger{Float32, PortAudio.SampledSignalsWriter, Tuple{Matrix{Float32}, Int64, Int64}, Int64}, PortAudio.Messanger{Float32, PortAudio.SampledSignalsReader, Tuple{Matrix{Float32}, Int64, Int64}, Int64}}})()
    @ Main ./threadingconstructs.jl:169d

The fact that it fails silently seems to me to be the more serious issue here, though I'm also curious why this apparent type mismatch occurs.

Version info:

julia> versioninfo()
Julia Version 1.6.4
Commit 35f0c911f4 (2021-11-19 03:54 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.5.0)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, haswell)
Environment:
  JULIA_PKG_ENV = synth

(synth) pkg> status
      Status `~/Desktop/CS/julia/synth/Project.toml`
  [717857b8] DSP v0.6.10
  [ee78f7c6] Makie v0.15.3
  [80ea8bcb] PortAudio v1.1.2
  [bd7594eb] SampledSignals v2.1.2
@JRice15
Copy link
Author

JRice15 commented Nov 25, 2021

Found an even cleaner example of the issue. Running the following script works as expected:

using PortAudio
in_stream = PortAudioStream(1, 0; latency = 0.01)
throw(DivideError())

unless, you supply the --threads N argument to Julia, where N>1. Then it fails silently at the throw.

@bramtayl
Copy link
Member

Thanks for the report! This would be good to fix. We probably should run these examples as part of CI to make sure they run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants