Skip to content

Commit

Permalink
safari: Change terser configuration to workaround threejs/terser inco…
Browse files Browse the repository at this point in the history
…mpatibility (tensorflow#5495)

Users have reported problems loading TensorBoard in Safari: tensorflow#5489

Thanks to @severo and @bileschi we were able to identify the problem to an incompatibility between threejs (which we use for WebGL rendering) and terser (which we use for minimizing/optimizing our code). 

Angular encountered this problem last year and worked around it by changing their terser config by reducing number of passes from 3 to 2: 
* angular/angular-cli#21107
* angular/angular-cli@2c2b499

In our case I have to reduce the number of terser passes from 3 to 1. For some reason reducing to 2 does not solve the problem.

This change surprisingly appears to reduce binary size. Before this change the size of index.js is 7672844 bytes. After this change the size of index.js is 7670992 bytes -- reducing binary size by 1852 bytes.
  • Loading branch information
bmd3k authored and dna2github committed May 1, 2023
1 parent 54b4bb2 commit bc06a3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tensorboard/defs/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def tf_js_binary(
terser_minified(
name = internal_result_name,
src = internal_rollup_name,
# Notes about the terser config:
# compress.passes - this is set to '1' to workaround issue with
# terser and threejs. In practice it (surprisingly) generates
# smaller results than when it was previously set to '3'.
config_file = "//tensorboard/defs:terser_config.json",
visibility = ["//visibility:private"],
sourcemap = False,
Expand Down
2 changes: 1 addition & 1 deletion tensorboard/defs/terser_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
},
"compress": {
"keep_fnames": true,
"passes": 3,
"passes": 1,
"pure_getters": true,
"reduce_funcs": true,
"reduce_vars": true,
Expand Down

0 comments on commit bc06a3a

Please sign in to comment.