visgl / deck.gl

WebGL2 powered visualization framework
https://deck.gl
MIT License
12.24k stars 2.08k forks source link

Significant performance regression in MacOS Safari 14.1.2 #6133

Open delfrrr opened 3 years ago

delfrrr commented 3 years ago

Description

I've notice significant performance regression while using dekart.xyz (open source data-analytics built on top of deck.gl); Presumably it happens after minor MacOs update. In a same time (same OS and same hardware) Chrome performance is not affected. To reproduce the issue I've created example with H3HexagonLayer (22k rows of data) based on deck.gl provided examples to make sure problem is with deck.gl and not something else. I've added stats.js to show FPS drop

Link to example https://github.com/dekart-xyz/deck.gl/tree/slow-safari/examples/get-started/pure-js/slow-safari

Screenshot 2021-08-25 at 08 04 29

In Safari FPS drops to below 10 when zooming in/out

Screenshot 2021-08-25 at 08 08 02

In Chrome FPS is not affected when zoom in/out

PLEASE NOTE: Safari is 18% worldwide and 35% in US. Currently all deck.gl visualisations are not usable in Safari! I was able to reproduce this issues on 3 different MacBooks

Expected Behavior

No FPS drops when zooming in and zooming out

Repro Steps

Environment

Logs

Nothing special in logs

Pessimistress commented 3 years ago

When you say "regression", are you comparing to earlier versions of deck.gl, or earlier versions of Safari?

Although Safari is not as good as Chrome in WebGL compatibility and performance, it's not that far off. Something you should try are:

glOptions: {powerPreference: 'high-performance'}

Safari is 18% worldwide and 35% in US

I do not think so: https://browserslist.dev/?q=PjElIGluIHVz Majority of the Safari traffic is from iOS. The desktop version in particular, share is less than FF and no where near Chrome.

delfrrr commented 3 years ago

@Pessimistress hey thank you for reply

As I said I use app build on top of deck.gl on daily basis, performance in Safari was great. Somewhere mid summer after time off I realised that everything become very slow; I think it's regression after updating to Safari 14.1.1 or 14.1.2 which came with automatic update. I did simple example with deck.gl to localise problem, see links above.

It's does nor reproduce on iOS but does reproduce on 2 other Mac Books I could access to try.

Used browser share from here https://gs.statcounter.com/browser-market-share you are right about mobile, but there is still 18% (second most popular browser)

StatCounter-browser-US-monthly-202007-202107-2

I will try suggested solution and update here

delfrrr commented 3 years ago

Tried suggested solutions:

Pessimistress commented 3 years ago

Removing the bug label since this is a not a breakage in our code base. We make our best effort to follow WebGL best practice but the outcome is always bound by the performance of the browser itself. Regarding Safari, it's always been a bit of a moving target, with its lagging-behind support for WebGL specs, and hardware-specific shader compilation bugs as Macs cruised through various chip providers.

I do not have a MacBook myself and I am unable to reproduce the reported issue on my desktop. If a localized performance bottleneck in Safari could be identified, we would patch it as long as the impact to other platforms is low. I suspect it's not worth the effort to investigate given that Safari 15 is coming in a few weeks with a reengineered WebGL engine.

Thank you for bringing this to our attention but I do not see a clear action item at this moment.

Pessimistress commented 3 years ago

Actually, can you share the information that you see in https://webglreport.com/?v=1 in Safari?

delfrrr commented 3 years ago

Results from https://webglreport.com/?v=1

Screenshot 2021-09-06 at 07 14 45

Platform: | MacIntel
-- | --
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.2 Safari/605.1.15
webgl
WebGL 1.0
WebGL GLSL ES 1.0 (1.0)
WebKit
WebKit WebGL
Apple Inc.
Apple GPU
Available
No
No

Supported Extensions:
--
  | EXT_blend_minmax
  | EXT_sRGB
  | EXT_frag_depth
  | OES_texture_float
  | OES_texture_float_linear
  | OES_texture_half_float
  | OES_texture_half_float_linear
  | OES_standard_derivatives
  | EXT_shader_texture_lod
  | EXT_texture_compression_rgtc
  | EXT_texture_filter_anisotropic
  | OES_vertex_array_object
  | OES_element_index_uint
  | OES_fbo_render_mipmap
  | WEBGL_lose_context
  | WEBGL_compressed_texture_s3tc
  | WEBGL_compressed_texture_s3tc_srgb
  | WEBGL_depth_texture
  | WEBGL_draw_buffers
  | ANGLE_instanced_arrays
  | WEBGL_debug_shaders
  | WEBGL_debug_renderer_info
  | EXT_color_buffer_half_float
  | EXT_float_blend
  | WEBGL_color_buffer_float
  | KHR_parallel_shader_compile
delfrrr commented 3 years ago

@Pessimistress performance in Safari 15 unfortunately is the same

Screenshot 2021-09-06 at 07 17 48
Pessimistress commented 3 years ago

It seems that the problem applies to all WebGL applications:

https://discourse.threejs.org/t/horrible-3d-three-js-performance-in-latest-safari-on-macos/25940/10

I understand how frustrating this issue is for you, but at this moment it's not clear to me what we can do to make it better. Some steps you can take to narrow in on the problem are:

If you can find that e.g. some layers work better than others, or even some other libraries work better, then we may be able to identify a work around. However, if WebGL performance in Safari all across the board is low, then it's not something we can fix in JavaScript, and you should really report it as a bug to WebKit.

delfrrr commented 3 years ago

@Pessimistress

found one example with same big difference https://threejs.org/examples/#webgl_animation_keyframes when zoom in close to house, fps drop a lot in safari, same as deck.gl vis;

other example seems fine (60 FPS)

I did file a bug to Safari (https://webkit.org/reporting-bugs/ says Safari is not WebKit) 10 days ago; latest WebKit release crashes on my laptop

Pessimistress commented 3 years ago

cc @ibgreen and @alasarr I am unable to reproduce this with either Safari 14.1 or 15.0 TP, though I have a somewhat unusual setup (Mac Mini + eGPU). I find the reported issue a little sus considering it's not even that many instances. I'd be interested to see if anyone else is experiencing the same.

kylebarron commented 3 years ago

I updated my Safari to 14.1.2 and can reproduce with the original codepen (https://codepen.io/delfrrr/pen/oNwgrNw). Safari is quite significantly slower than Chrome when zooming in and out. This persists even when forcing the discrete GPU with gfx.io. (I forgot to test with the previous 14.0.x version of Safari I had installed previously).

Versions:

macOS Big Sur 11.5.2

  Model Name:   MacBook Pro
  Model Identifier: MacBookPro16,1
  Processor Name:   8-Core Intel Core i9
  Processor Speed:  2.3 GHz
  Number of Processors: 1
  Total Number of Cores:    8
  L2 Cache (per Core):  256 KB
  L3 Cache: 16 MB
  Hyper-Threading Technology:   Enabled
  Memory:   16 GB

Graphics cards:

Intel UHD Graphics 630
AMD Radeon Pro 5500M
Pessimistress commented 3 years ago

With your test repo, can you try clearing the lock file and pull the latest @luma.gl/* dependencies (8.5.7)?

The pre-bundled version does not include the latest changes.

delfrrr commented 3 years ago

@Pessimistress tested with @luma 8.5.7; there is no difference

I could localise issue better and understand why I did not observe it before in Safari! Apparently problem was with dataset: after update it has many duplicates (~4 per each H3 index) and for some reason deck.gl is very slow in Safari when there are multiple hexagons with same index:

Pessimistress commented 3 years ago

Interesting discovery... could you try adding parameters: {blend: false} to the layer + dataset with duplicates and see if it makes a difference?

delfrrr commented 3 years ago

I would not say blend: false does difference (maybe small one), but

  parameters: {
    blend: false,
    depthTest: false
  },

makes it at least 2-3x faster; still laggy but almost usable

delfrrr commented 3 years ago

also please not that issue reproduced when you zoom in closely and does not when you zoom out

performance ok

Screenshot 2021-09-19 at 08 08 58

Performance not ok

Screenshot 2021-09-19 at 08 09 27