Skip to content

Commit

Permalink
Improve CairoMakie thread safety (#3777)
Browse files Browse the repository at this point in the history
* improve cairomakie thread safety

* add changelog entry
  • Loading branch information
jkrumbiegel authored Apr 10, 2024
1 parent 139ddb1 commit d47671d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

- Improved thread safety of rendering with CairoMakie (independent `Scene`s only) by locking FreeType handles [#3777](https://github.com/MakieOrg/Makie.jl/pull/3777).

## [0.20.9] - 2024-03-29

- Added supported markers hint to unsupported marker warn message [#3666](https://github.com/MakieOrg/Makie.jl/pull/3666).
Expand Down
2 changes: 1 addition & 1 deletion CairoMakie/src/cairo-extension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ end

function set_ft_font(ctx, font)

font_face = ccall(
font_face = Base.@lock font.lock ccall(
(:cairo_ft_font_face_create_for_ft_face, Cairo.libcairo),
Ptr{Cvoid}, (Makie.FreeTypeAbstraction.FT_Face, Cint),
font, 0
Expand Down
4 changes: 2 additions & 2 deletions CairoMakie/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ Finds a font that can represent the unicode character!
Returns Makie.defaultfont() if not representable!
"""
function best_font(c::Char, font = Makie.defaultfont())
if Makie.FreeType.FT_Get_Char_Index(font, c) == 0
if Base.@lock font.lock Makie.FreeType.FT_Get_Char_Index(font, c) == 0
for afont in Makie.alternativefonts()
if Makie.FreeType.FT_Get_Char_Index(afont, c) != 0
if Base.@lock afont.lock Makie.FreeType.FT_Get_Char_Index(afont, c) != 0
return afont
end
end
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ FilePaths = "0.8"
FixedPointNumbers = "0.6, 0.7, 0.8"
Format = "1.3"
FreeType = "3.0, 4.0"
FreeTypeAbstraction = "0.10"
FreeTypeAbstraction = "0.10.3"
GeometryBasics = "0.4.2"
GridLayoutBase = "0.10"
ImageIO = "0.2, 0.3, 0.4, 0.5, 0.6"
Expand Down

0 comments on commit d47671d

Please sign in to comment.