From db474a47b70e4fa50f594f4dea8a2f531ca9fc07 Mon Sep 17 00:00:00 2001 From: Andrey Tserkus Date: Tue, 28 Jul 2020 17:18:08 -0700 Subject: [PATCH] RN: Fixed `performanceNow()` to allow debugging in Chrome Summary: Discovered when debugging a React Native app in Chrome. The function `performanceNow` was recently changed, so that in Chrome it now refers to `performance.now()` method. However, `now()` cannot be called standalone without a context. Reproduced by a synthetic example in Chrome: ``` const performanceNow = window.performance.now; performanceNow(); Uncaught TypeError: Illegal invocation at :1:1 ``` Changelog: [General] [Fixed] - Fix failure when debugging code in a browser; was caused by `performanceNow()` function. Reviewed By: cpojer Differential Revision: D22739176 fbshipit-source-id: f89b8a215b7b4c430ffd72a1d23539c4f1b31d24 --- Libraries/Utilities/createPerformanceLogger.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/Utilities/createPerformanceLogger.js b/Libraries/Utilities/createPerformanceLogger.js index e30b42165bf0da..d53c107b3e4f0e 100644 --- a/Libraries/Utilities/createPerformanceLogger.js +++ b/Libraries/Utilities/createPerformanceLogger.js @@ -13,7 +13,8 @@ const Systrace = require('../Performance/Systrace'); const infoLog = require('./infoLog'); -const performanceNow = global.nativeQPLTimestamp ?? global.performance.now; +const performanceNow = + global.nativeQPLTimestamp ?? global.performance.now.bind(global.performance); type Timespan = { description?: string,