Replies: 5 comments 6 replies
-
This is an interesting idea, overall sounds good to me in order to boost performance. |
Beta Was this translation helpful? Give feedback.
-
If I may throw in my 2 cents, I believe that css colors are a well-known and recognized system for conveying color information, I think there is no point in introducing a new convention of our own just for performance reasons. In any case, a good start would be to compare the parsing time of the sample JSON style with colors defined according to the css color specification and the other one where colors are defined in the format proposed here to show the difference on a realistic example. I assume the difference would be a few milliseconds at most - but well, I could be wrong :) |
Beta Was this translation helpful? Give feedback.
-
This format will duplicate the rgb()/rgba() syntax from css color 3: My thoughts on color parsing performance:
@pramilk would you be so kind as to count how many duplicate colors are among these 158 hex and 201 hsl in bing maps? maptiler-streets (maplibre default?): |
Beta Was this translation helpful? Give feedback.
-
Thanks @kajkal. I see 50% improvement with caching and further 50% with using JSON array. I will hold on to current PR #189 and will first get the caching done. If there is still need will relook into JSON Array. |
Beta Was this translation helpful? Give feedback.
-
The topic was discussed in the TSC meeting today but there were no real inputs in that meeting. |
Beta Was this translation helpful? Give feedback.
-
Currently only CSS style (Hex/RGB/RGBA/HSL) colors are supported for a string color input. Color array is supported via expressions. All of these methods are much slower (30-60%) than a simple RGBA color array. Overhead of expressions makes it even slower than using CSS color string. Currently about 5-8% of Style parsing time is spent on color parsing which is a on a hot code path and is done on both main and worker thread.
Current supported formats:
"red"
"rgb(25 ,0 ,0)"
"#ff3322"
"hsl(120 50% 80%)"
New additional format:
"[25 ,10 , 10]"
"[25 ,10 ,10 , 0.4]"
If this is something we agree can be supported then I can make the changes.
Test: https://jsbench.me/84li0k8nkg/1
Beta Was this translation helpful? Give feedback.
All reactions