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

StackOverflowError when attempting undefined color space conversion #465

Closed
kimikage opened this issue Mar 22, 2021 · 1 comment · Fixed by #466
Closed

StackOverflowError when attempting undefined color space conversion #465

kimikage opened this issue Mar 22, 2021 · 1 comment · Fixed by #466

Comments

@kimikage
Copy link
Collaborator

Although undefined color space conversion should result in an error, the error message is not helpful.

julia> using ColorTypes

julia> struct MyColor{T} <: Color{T, 3}; c1::T; c2::T; c3::T; end

julia> convert(RGB, MyColor{Float32}(1, 2, 3)) # without Colors.jl
ERROR: No conversion of MyColor{Float32}(1.0f0,2.0f0,3.0f0) to RGB{Float32} has been defined

julia> using Colors

julia> convert(RGB, MyColor{Float32}(1, 2, 3)) # with Colors.jl
ERROR: StackOverflowError:

A fix for this issue could theoretically affect downstream packages. However, given that there have been no issue reports on this so far, I think it can be included in the v0.12 series as a bug fix in practice.

@kimikage
Copy link
Collaborator Author

This is due to the circular calls between the conversion to RGB and the conversion to XYZ.

From the viewpoint of color management, I think the conversion to XYZ should be implemented preferentially over the conversion to RGB, but in actual cases where the stack overflow is a problem, the conversion to RGB seems to be defined preferentially.

Also, due to historical reasons, we currently limit the conversion source to Color3, but I think this should be more generalized.

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

Successfully merging a pull request may close this issue.

1 participant