mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Create Snapshot From Stream
Summary: Adding an instrumentation endpoint that allows us to write a snapshot out to an arbitrary output stream. This is in addition to `createSnapshotFromFile`. I reserve the right to replace the latter with the former in a later diff. This is necessary to allow snapshots to be requested over the chrome debugger protocol. The protocol sends the snapshot over the wire in chunks so we need to be able to use an output stream that can do the chunking. Because LLVM types are not available at the JSI layer, we accept a `std::ostream` reference which we wrap with `llvm::raw_os_ostream` within Hermes. We should not incur the static initializer cost (or other code bloat) of using ostreams as a result. Reviewed By: cwdick Differential Revision: D16016319 fbshipit-source-id: 2d0b4848fd5cbe9ddee371d856cd8eb19dd80396
This commit is contained in:
committed by
Facebook Github Bot
parent
18eba792dd
commit
14686259d9
@@ -337,6 +337,10 @@ class RuntimeDecorator : public Base, private jsi::Instrumentation {
|
||||
return plain().instrumentation().createSnapshotToFile(path, compact);
|
||||
}
|
||||
|
||||
bool createSnapshotToStream(std::ostream& os, bool compact) override {
|
||||
return plain().instrumentation().createSnapshotToStream(os, compact);
|
||||
}
|
||||
|
||||
void writeBridgeTrafficTraceToFile(
|
||||
const std::string& fileName) const override {
|
||||
const_cast<Plain&>(plain()).instrumentation().writeBridgeTrafficTraceToFile(
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
#include <jsi/jsi.h>
|
||||
@@ -55,6 +56,15 @@ class Instrumentation {
|
||||
/// \return true iff the heap capture succeeded
|
||||
virtual bool createSnapshotToFile(const std::string& path, bool compact) = 0;
|
||||
|
||||
/// Captures the heap to an output stream
|
||||
///
|
||||
/// \param os output stream to write to.
|
||||
///
|
||||
/// \param compact Whether the JSON should be compact or pretty
|
||||
///
|
||||
/// \return true iff the heap capture succeeded.
|
||||
virtual bool createSnapshotToStream(std::ostream& os, bool compact) = 0;
|
||||
|
||||
/// Write a trace of bridge traffic to the given file name.
|
||||
virtual void writeBridgeTrafficTraceToFile(
|
||||
const std::string& fileName) const = 0;
|
||||
|
||||
@@ -81,6 +81,10 @@ Instrumentation& Runtime::instrumentation() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool createSnapshotToStream(std::ostream&, bool) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
void writeBridgeTrafficTraceToFile(const std::string&) const override {
|
||||
std::abort();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user