resurrect rn-snoopy and add some comments

This commit is contained in:
Roman Volosovskyi 2019-06-27 13:35:41 +03:00
parent 2b6bfb9851
commit 6d1b376221
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
10 changed files with 24 additions and 16 deletions

2
.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

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

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

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

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

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

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

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

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

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