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

Use StableTasks to pin the thread of the renderloop on MacOS #4779

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Fixed issue with `WGLMakie.voxels` not rendering on linux with firefox [#4756](https://github.com/MakieOrg/Makie.jl/pull/4756)
- Cleaned up surface handling in GLMakie: Surface cells are now discarded when there is a nan in x, y or z. Fixed incorrect normal if x or y is nan [#4735](https://github.com/MakieOrg/Makie.jl/pull/4735)
- Cleaned up `volume` plots: Added `:indexedabsorption` and `:additive` to WGLMakie, generalized `:mip` to include negative values, fixed missing conversions for rgba algorithms (`:additive`, `:absorptionrgba`), fixed missing conversion for `absorption` attribute & extended it to `:indexedabsorption` and `absorptionrgba`, added tests and improved docs. [#4726](https://github.com/MakieOrg/Makie.jl/pull/4726)
- Fixed issue with `GLMakie.Screen` not being on the main thread, causing rendering issues on macOS. [#4779](https://github.com/MakieOrg/Makie.jl/pull/4779)

## [0.22.1] - 2025-01-17

Expand Down
2 changes: 2 additions & 0 deletions GLMakie/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
ShaderAbstractions = "65257c39-d410-5151-9873-9b3e5be5013e"
StableTasks = "91464d47-22a1-43fe-8b7f-2d57ee82463f"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[compat]
Expand All @@ -38,5 +39,6 @@ Observables = "0.5.1"
PrecompileTools = "1.0"
Printf = "1.0, 1.6"
ShaderAbstractions = "0.5"
StableTasks = "0.1"
StaticArrays = "0.12, 1.0"
julia = "1"
2 changes: 1 addition & 1 deletion GLMakie/src/GLMakie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using ShaderAbstractions
using FreeTypeAbstraction
using GeometryBasics: StaticVector
using Observables

using StableTasks
using Base: RefValue
import Base: push!, isopen, show
using Base.Iterators: repeated, drop
Expand Down
13 changes: 10 additions & 3 deletions GLMakie/src/screen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ mutable struct Screen{GLWindow} <: MakieScreen
framebuffer::GLFramebuffer
config::Union{Nothing, ScreenConfig}
stop_renderloop::Threads.Atomic{Bool}
rendertask::Union{Task, Nothing}
rendertask::Union{StableTasks.StableTask, Nothing}
timer::BudgetedTimer


Expand Down Expand Up @@ -196,7 +196,7 @@ mutable struct Screen{GLWindow} <: MakieScreen
framebuffer::GLFramebuffer,
config::Union{Nothing, ScreenConfig},
stop_renderloop::Bool,
rendertask::Union{Nothing, Task},
rendertask::Union{Nothing, StableTasks.StableTask},

screen2scene::Dict{WeakRef, ScreenID},
screens::Vector{ScreenArea},
Expand Down Expand Up @@ -913,7 +913,14 @@ function start_renderloop!(screen::Screen)
return
else
screen.stop_renderloop[] = false
task = @async screen.config.renderloop(screen)
# On Mac, only the main thread can render,
# so we need to fix the task to be on the main thread
# (which is, I am assuming, threadid 1).
task = @static if Sys.isapple()
StableTasks.@spawnat 1 screen.config.renderloop(screen)
else
StableTasks.@spawn screen.config.renderloop(screen)
end
yield()
if istaskstarted(task)
screen.rendertask = task
Expand Down
Loading