Repository navigation
Avoid use of 'new Function' when it is prohibited by CSP - #5665
Conversation
|
This works, insofar as it allows GL JS to operate in the absense of the
|
|
Any idea where the reduced paint performance comes from? Offhand I wouldn't expect that, since painting doesn't make much use of filters or |
|
@jfirebaugh I haven't profiled yet, but I figured it was due to some of the symbol placement stuff that uses |
|
Here's some rough math to estimate how much filter evaluation contributes to tile processing time: The So, for a style like Thus, we'd expect the 3-4x increase in filter evaluation time caused by using expressions instead of eval to appear as a 3-4% increase in layout time; and, indeed, benchmarking just the filter change: https://bl.ocks.org/anonymous/raw/292bf0bf3cb060ec1dd92a1c1fd05d28/. Given these figures, should we keep the eval-based path for filters, or just take the 3-4% increase in layout time in return for having a single code path? |
|
I'm definitely in favor of having a single code path. Let's implement the static buffer layouts and then check layout performance again -- static buffer layouts should be even faster than dynamic, eval'ed |
👍 agreed - I started working on this yesterday, based on your property-refactor branch. |
a692938 to
954dc89
Compare
|
Just rebased this branch on
Since that refactor didn't improve the time on the Worth noting, though, that |
e723086 to
e248dad
Compare
|
Current benchmark results: https://bl.ocks.org/anonymous/raw/d34a550b987e7dcb991155067c25d6d5/ They haven't changed much from #5665 (comment), but now include a 0.43.0 comparison. |
|
I was able to find an optimization in earcut that counterbalances the effect of this change on the |
|
Do we have any timeline for releasing this fix? |
|
@zlk89 it will be included in the 0.44 release, which should be coming soon. You can watch https://github.com/mapbox/mapbox-gl-js/milestone/25 to follow progress |
|
@jfirebaugh – I've noticed that the Mapbox website (how-to-use-mapbox-securely/#csp-directives) still mentions that |
Fixes #559
Changes:
new Function()is unavailable, generate StructArray accessors using closures rather than compiling strings.new Function()is unavailableBenchmarks
There's definitely a performance hit when eval is disabled. Benchmarks with significant change:
All: https://bl.ocks.org/anonymous/raw/d24cf0531c261480dbdd8301c21cbd49/
Launch Checklist