Browse Source

resurrect rn-snoopy and add some comments

tags/pre-yarn2nix-push
Roman Volosovskyi 1 month ago
parent
commit
6d1b376221
No account linked to committer's email address

+ 1
- 1
.env View File

@@ -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

+ 1
- 1
.env.e2e View File

@@ -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

+ 1
- 1
.env.jenkins View File

@@ -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

+ 1
- 1
.env.nightly View File

@@ -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

+ 1
- 1
.env.nightly.staging.fleet View File

@@ -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

+ 1
- 1
.env.prod View File

@@ -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

+ 1
- 0
react-native/src/desktop/status_im/react_native/js_dependencies.cljs View File

@@ -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"))

+ 1
- 0
react-native/src/mobile/status_im/react_native/js_dependencies.cljs View File

@@ -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"))

+ 1
- 1
src/status_im/utils/config.cljs View File

@@ -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)))

+ 15
- 9
src/status_im/utils/snoopy.cljs View File

@@ -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

Loading…
Cancel
Save