diff --git a/.env b/.env index cfa3bf45f2..a60dc47e03 100644 --- a/.env +++ b/.env @@ -15,7 +15,7 @@ PFS_ENCRYPTION_ENABLED=1 PFS_TOGGLE_VISIBLE=1 POW_TARGET=0.002 POW_TIME=1 -RN_BRIDGE_THRESHOLD_WARNINGS=0 +SNOOPY=0 RPC_NETWORKS_ONLY=0 STICKERS_ENABLED=1 PARTITIONED_TOPIC=0 diff --git a/.env.e2e b/.env.e2e index cfea310513..6cdf4ebb43 100644 --- a/.env.e2e +++ b/.env.e2e @@ -13,7 +13,7 @@ PFS_ENCRYPTION_ENABLED=1 PFS_TOGGLE_VISIBLE=1 POW_TARGET=0.002 POW_TIME=1 -RN_BRIDGE_THRESHOLD_WARNINGS=0 +SNOOPY=0 STICKERS_ENABLED=1 PARTITIONED_TOPIC=0 CONTRACT_NODES=1 diff --git a/.env.jenkins b/.env.jenkins index 4e156ade98..e4c2c372a5 100644 --- a/.env.jenkins +++ b/.env.jenkins @@ -15,7 +15,7 @@ PFS_ENCRYPTION_ENABLED=1 PFS_TOGGLE_VISIBLE=1 POW_TARGET=0.002 POW_TIME=1 -RN_BRIDGE_THRESHOLD_WARNINGS=0 +SNOOPY=0 RPC_NETWORKS_ONLY=0 STICKERS_ENABLED=1 PARTITIONED_TOPIC=0 diff --git a/.env.nightly b/.env.nightly index 8a876fb3db..1375dc8351 100644 --- a/.env.nightly +++ b/.env.nightly @@ -13,7 +13,7 @@ PFS_ENCRYPTION_ENABLED=1 PFS_TOGGLE_VISIBLE=1 POW_TARGET=0.002 POW_TIME=1 -RN_BRIDGE_THRESHOLD_WARNINGS=0 +SNOOPY=0 RPC_NETWORKS_ONLY=0 STICKERS_ENABLED=0 PARTITIONED_TOPIC=0 diff --git a/.env.nightly.staging.fleet b/.env.nightly.staging.fleet index 0e09644bba..cbcb9abfc2 100644 --- a/.env.nightly.staging.fleet +++ b/.env.nightly.staging.fleet @@ -13,7 +13,7 @@ PFS_ENCRYPTION_ENABLED=1 PFS_TOGGLE_VISIBLE=1 POW_TARGET=0.002 POW_TIME=1 -RN_BRIDGE_THRESHOLD_WARNINGS=0 +SNOOPY=0 STICKERS_ENABLED=0 PARTITIONED_TOPIC=0 CONTRACT_NODES=1 diff --git a/.env.prod b/.env.prod index e36faf223f..b624f78d8a 100644 --- a/.env.prod +++ b/.env.prod @@ -13,7 +13,7 @@ PFS_ENCRYPTION_ENABLED=1 PFS_TOGGLE_VISIBLE=0 POW_TARGET=0.002 POW_TIME=1 -RN_BRIDGE_THRESHOLD_WARNINGS=0 +SNOOPY=0 RPC_NETWORKS_ONLY=1 STICKERS_ENABLED=0 PARTITIONED_TOPIC=0 diff --git a/react-native/src/desktop/status_im/react_native/js_dependencies.cljs b/react-native/src/desktop/status_im/react_native/js_dependencies.cljs index e0f847d545..79d1708fd4 100644 --- a/react-native/src/desktop/status_im/react_native/js_dependencies.cljs +++ b/react-native/src/desktop/status_im/react_native/js_dependencies.cljs @@ -10,6 +10,7 @@ (def realm (js/require "realm")) (def webview-bridge (js/require "react-native-webview-bridge")) (def webview #js {:WebView #js {}}) +(def EventEmmiter (fn [] #js {})) (def securerandom (js-require/js-require "react-native-securerandom")) (defn secure-random [] (.-generateSecureRandom (securerandom))) (def fetch-polyfill (js-require/js-require "react-native-fetch-polyfill")) diff --git a/react-native/src/mobile/status_im/react_native/js_dependencies.cljs b/react-native/src/mobile/status_im/react_native/js_dependencies.cljs index 00656e4e21..933271ba00 100644 --- a/react-native/src/mobile/status_im/react_native/js_dependencies.cljs +++ b/react-native/src/mobile/status_im/react_native/js_dependencies.cljs @@ -13,6 +13,7 @@ (def touchid-class (js-require/js-require "react-native-touch-id")) (defn touchid [] (.-default (touchid-class))) (def webview (js-require/js-require "react-native-webview")) +(def EventEmmiter (js-require/js-require "react-native/Libraries/vendor/emitter/EventEmitter")) (def securerandom (js-require/js-require "react-native-securerandom")) (defn secure-random [] (.-generateSecureRandom (securerandom))) (def fetch-polyfill (js-require/js-require "react-native-fetch-polyfill")) diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index 6746543c8f..5ad12f7a08 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -25,7 +25,7 @@ (def mainnet-warning-enabled? (enabled? (get-config :MAINNET_WARNING_ENABLED 0))) (def pairing-popup-disabled? (enabled? (get-config :PAIRING_POPUP_DISABLED "0"))) (def cached-webviews-enabled? (enabled? (get-config :CACHED_WEBVIEWS_ENABLED 0))) -(def rn-bridge-threshold-warnings-enabled? (enabled? (get-config :RN_BRIDGE_THRESHOLD_WARNINGS 0))) +(def snoopy-enabled? (enabled? (get-config :SNOOPY 0))) (def extensions-enabled? (enabled? (get-config :EXTENSIONS 0))) (def stickers-enabled? (enabled? (get-config :STICKERS_ENABLED 0))) (def hardwallet-enabled? (enabled? (get-config :HARDWALLET_ENABLED 0))) diff --git a/src/status_im/utils/snoopy.cljs b/src/status_im/utils/snoopy.cljs index d9ea912163..e92cc94304 100644 --- a/src/status_im/utils/snoopy.cljs +++ b/src/status_im/utils/snoopy.cljs @@ -2,10 +2,10 @@ (:require [status-im.react-native.js-dependencies :as js-dependencies] [status-im.utils.config :as config])) -(defn snoopy [] (.-default js-dependencies/snoopy)) -(defn sn-filter [] (.-default js-dependencies/snoopy-filter)) -(defn bars [] (.-default js-dependencies/snoopy-bars)) -(defn buffer [] (.-default js-dependencies/snoopy-buffer)) +(defn snoopy [] (.-default (js-dependencies/snoopy))) +(defn sn-filter [] (.-default (js-dependencies/snoopy-filter))) +(defn bars [] (.-default (js-dependencies/snoopy-bars))) +(defn buffer [] (.-default (js-dependencies/snoopy-buffer))) (defn create-filter [f] (fn [message] @@ -67,11 +67,17 @@ print-events?) events))))) +;; In order to enable snoopy set SNOOPY=1 in .env file. +;; By default events are not printed and you will see warnings only when +;; the number of events is exceeding the threshold. +;; For debugging UI perf, in particular the number of bridge calls caused +;; by view components set `:print-events?=true` for `ui-manager-filter`, +;; and then collect printed data in logs. (defn subscribe! [] - (when config/rn-bridge-threshold-warnings-enabled? - ;;(js-dependencies/EventEmmiter.) - (let [emitter nil - events (.stream (snoopy) emitter)] + (when config/snoopy-enabled? + (let [emitter-class (js-dependencies/EventEmmiter) + emitter (emitter-class.) + events (.stream (snoopy) emitter)] (threshold-warnings {:filter-fn (constantly true) :label "all messages" @@ -96,7 +102,7 @@ :threshold-message (str "too many calls to UIManager, most likely during navigation. " "Please consider preloading of screens or lazy loading of some components") :tick? false - :print-events? false + :print-events? true ;; todo(rasom): revisit this number when/if ;; https://github.com/status-im/status-react/pull/2849 will be merged :threshold 200