Skip to content
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

BoundsError in recordframe! with WGLMakie #3961

Closed
2 tasks done
baggepinnen opened this issue Jun 14, 2024 · 5 comments · May be fixed by #4466
Closed
2 tasks done

BoundsError in recordframe! with WGLMakie #3961

baggepinnen opened this issue Jun 14, 2024 · 5 comments · May be fixed by #4466
Labels
bug File IO & display save, record, display rendering typically backend specific WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.

Comments

@baggepinnen
Copy link

baggepinnen commented Jun 14, 2024

  • are you running newest version (version from docs) ?
  • can you reproduce the bug with a fresh environment ? (]activate --temp; add Makie)
  • What platform + GPU are you on? Ubuntu + NVidia GeForce RTX 3080

When creating animations, I can use GLMakie or CairoMakie without problems, but with WGLMakie I get

ERROR: BoundsError: attempt to access 600×450 Array{RGB{N0f8},2} with eltype RGB{FixedPointNumbers.N0f8} at index [1:721, 1:541]
Stacktrace:
  [1] throw_boundserror(A::Matrix{RGB{FixedPointNumbers.N0f8}}, I::Tuple{UnitRange{Int64}, UnitRange{Int64}})
    @ Base ./abstractarray.jl:737
  [2] checkbounds
    @ ./abstractarray.jl:702 [inlined]
  [3] view(::Matrix{RGB{FixedPointNumbers.N0f8}}, ::UnitRange{Int64}, ::UnitRange{Int64})
    @ Base ./subarray.jl:184
  [4] recordframe!(io::Makie.VideoStream)
    @ Makie ~/.julia/packages/Makie/We6MY/src/ffmpeg-util.jl:245
  [5] Record(func::Render.var"#72#73"{}, figlike::Makie.Figure, iter::StepRangeLen{…}; kw_args::@Kwargs{})
    @ Makie ~/.julia/packages/Makie/We6MY/src/recording.jl:174
  [6] record(func::Function, figlike::Makie.Figure, path::String, iter::StepRangeLen{…}; kw_args::@Kwargs{})
    @ Makie ~/.julia/packages/Makie/We6MY/src/recording.jl:154
  [7] record
    @ ~/.julia/packages/Makie/We6MY/src/recording.jl:152 [inlined]
  [8] render(model::ODESystem, sol::ODESolution{…}, timevec::Nothing; framerate::Int64, x::Int64, y::Int64, z::Int64, R::Matrix{…}, timescale::Float64, scene::Nothing, filename::String, kwargs::@Kwargs{})
    @ Render ~/.julia/dev/Multibody/ext/Render.jl:114

This code appears sufficient to reproduce

using WGLMakie

fig = Figure(size = (600, 600))
scene = LScene(fig[1, 1], scenekw = (lights = [DirectionalLight(RGBf(1, 1, 1), Vec3f(-1, 0, 0))],)); # scene is an LScene not its contained Scene
t = Observable(1.0)
thing = @lift Sphere(Point3f($t), 1f0)
mesh!(scene, thing, color = :white)
fig
record(fig, "test.gif", 0:0.1:1; framerate=5) do time # figure is used to record
    # @show time
    t[] = time
end

The problem is

    xdim, ydim = size(glnative)
    copy!(view(io.buffer, 1:xdim, 1:ydim), glnative)

where glnative has the wrong size for WGLMakie

@asinghvi17 asinghvi17 added the WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie. label Jun 14, 2024
@ffreyer ffreyer added rendering typically backend specific File IO & display save, record, display labels Aug 28, 2024
@ffreyer
Copy link
Collaborator

ffreyer commented Aug 28, 2024

This is a px_per_unit issue. Don't get it with the example above, but with record(..., px_per_unit = 2.0)

@mkitti
Copy link

mkitti commented Oct 8, 2024

I encountered this issue on a M1 Mac Studio.

julia> versioninfo()
Julia Version 1.10.5
Commit 6f3fdf7b362 (2024-08-27 14:19 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

The first solution I found was to activate with a screen config setting px_per_unit to 1.

WGLMakie.activate!(; px_per_unit=1)

This works, but produces a lower quality figure display.

The next solution I found was to make Base.size aware of px_per_unit:

Base.size(screen::WGLMakie.Screen) = size(screen.scene) .* Int(screen.config.px_per_unit)

@asinghvi17
Copy link
Member

Hmm, that's an interesting question. Should size(screen) mean number of physical pixels or number of logical pixels?

size(scene) currently means logical pixels, and it should probably stay that way, but the contexts in which you would invoke a screen's size are probably all about output handling, so you might want physical pixels there?

@mkitti
Copy link

mkitti commented Oct 8, 2024

size is used here:

_xdim, _ydim = size(screen)

I suppose one could also do the mulitplication there.

 _xdim, _ydim = size(screen) .* Int(screen.config.px_per_unit)

@rayegun
Copy link

rayegun commented Nov 28, 2024

Just got this with the Lorenz attractor example on the Makie.jl home page using Pluto. Some students ran into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug File IO & display save, record, display rendering typically backend specific WGLMakie This relates to WGLMakie.jl, the Web-based WebGL backend for Makie.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants