mirror of
https://github.com/status-im/react-native.git
synced 2025-01-30 19:25:11 +00:00
set JS profiling global to true, fix to parsing of strings with ascii value >=128
Reviewed By: @mkonicek Differential Revision: D2512320 fb-gh-sync-id: 098727cd664f0f0cdb0092875a9934a5d7b577f2
This commit is contained in:
parent
b5890e1283
commit
5d682d65f6
@ -28,6 +28,7 @@ import com.facebook.react.common.ReactConstants;
|
|||||||
import com.facebook.react.common.annotations.VisibleForTesting;
|
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||||
import com.facebook.infer.annotation.Assertions;
|
import com.facebook.infer.annotation.Assertions;
|
||||||
import com.facebook.systrace.Systrace;
|
import com.facebook.systrace.Systrace;
|
||||||
|
import com.facebook.systrace.TraceListener;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonFactory;
|
import com.fasterxml.jackson.core.JsonFactory;
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
@ -60,6 +61,7 @@ public class CatalystInstance {
|
|||||||
// Access from JS thread
|
// Access from JS thread
|
||||||
private @Nullable ReactBridge mBridge;
|
private @Nullable ReactBridge mBridge;
|
||||||
private @Nullable JavaScriptModuleRegistry mJSModuleRegistry;
|
private @Nullable JavaScriptModuleRegistry mJSModuleRegistry;
|
||||||
|
private @Nullable TraceListener mTraceListener;
|
||||||
|
|
||||||
private CatalystInstance(
|
private CatalystInstance(
|
||||||
final CatalystQueueConfigurationSpec catalystQueueConfigurationSpec,
|
final CatalystQueueConfigurationSpec catalystQueueConfigurationSpec,
|
||||||
@ -119,6 +121,45 @@ public class CatalystInstance {
|
|||||||
} finally {
|
} finally {
|
||||||
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mTraceListener = new TraceListener() {
|
||||||
|
@Override
|
||||||
|
public void onTraceStarted() {
|
||||||
|
mCatalystQueueConfiguration.getJSQueueThread().runOnQueue(
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mCatalystQueueConfiguration.getJSQueueThread().assertIsOnThread();
|
||||||
|
|
||||||
|
if (mDestroyed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Assertions.assertNotNull(mBridge).setGlobalVariable(
|
||||||
|
"__BridgeProfilingIsProfiling",
|
||||||
|
"true");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTraceStopped() {
|
||||||
|
mCatalystQueueConfiguration.getJSQueueThread().runOnQueue(
|
||||||
|
new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mCatalystQueueConfiguration.getJSQueueThread().assertIsOnThread();
|
||||||
|
|
||||||
|
if (mDestroyed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Assertions.assertNotNull(mBridge).setGlobalVariable(
|
||||||
|
"__BridgeProfilingIsProfiling",
|
||||||
|
"false");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Systrace.registerListener(mTraceListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ void callFunction(
|
/* package */ void callFunction(
|
||||||
@ -207,6 +248,10 @@ public class CatalystInstance {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mTraceListener != null) {
|
||||||
|
Systrace.unregisterListener(mTraceListener);
|
||||||
|
}
|
||||||
|
|
||||||
// We can access the Bridge from any thread now because we know either we are on the JS thread
|
// We can access the Bridge from any thread now because we know either we are on the JS thread
|
||||||
// or the JS thread has finished via CatalystQueueConfiguration#destroy()
|
// or the JS thread has finished via CatalystQueueConfiguration#destroy()
|
||||||
Assertions.assertNotNull(mBridge).dispose();
|
Assertions.assertNotNull(mBridge).dispose();
|
||||||
|
@ -60,6 +60,10 @@ public class ReactBridge extends Countable {
|
|||||||
JavaScriptExecutor jsExecutor,
|
JavaScriptExecutor jsExecutor,
|
||||||
ReactCallback callback,
|
ReactCallback callback,
|
||||||
MessageQueueThread nativeModulesQueueThread);
|
MessageQueueThread nativeModulesQueueThread);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All native functions are not thread safe and appropriate queues should be used
|
||||||
|
*/
|
||||||
public native void loadScriptFromAssets(AssetManager assetManager, String assetName);
|
public native void loadScriptFromAssets(AssetManager assetManager, String assetName);
|
||||||
public native void loadScriptFromNetworkCached(String sourceURL, @Nullable String tempFileName);
|
public native void loadScriptFromNetworkCached(String sourceURL, @Nullable String tempFileName);
|
||||||
public native void callFunction(int moduleId, int methodId, NativeArray arguments);
|
public native void callFunction(int moduleId, int methodId, NativeArray arguments);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user