Summary:
The Hermes inspector always logged the message for `console.assert`.
It instead should check the first argument, and only if that argument
is false should it log.
Also remove the polyfill code that tried to avoid this situation.
Changelog: [Internal]
Reviewed By: mhorowitz
Differential Revision: D22299186
fbshipit-source-id: cdf4f8957d4db3d171d6673a82c7fc32b7152af3
Summary:
`getStackTracesTreeNodeForAlloc` only works for memory that was tracked with `newAlloc`.
For now, that is only memory that goes through GC APIs.
Various places were calling this function on native memory which was allocated
with `malloc`, not GC memory. This led to SIGSEGV on nullptr when trying to take heap profiles
of these objects.
`newAlloc` could, in theory, work with native memory as well. But building out support for that
is outside the scope of this fix.
Changelog: [Internal]
Reviewed By: jbower-fb
Differential Revision: D21667842
fbshipit-source-id: 8403a6668e5ec607972ce6819f78fedb89da3f37
Summary:
This call is used to continue execution when the app has just been
started in a "wait for debugger" mode. This is the only case
in which it has an effect.
Notably, it should do nothing in the following cases, which a layperson
may be tempted to classify as "WaitingForDebugger":
* The app was running detached and hit a 'debugger;' statement
* The app is paused because of a breakpoint or hitting the Pause button
* The app stopped on an instrumentation breakpoint, and expects
the debugger to collect data and potentially auto-resume.
Changelog: [Internal] Add Hermes support for Debugger.runIfWaitingForDebugger
Reviewed By: mhorowitz
Differential Revision: D21557446
fbshipit-source-id: 790cec7444ddc61908d2ef9d92e4649b535d678f
Summary:
I noticed an issue when the hermes debugger was attached. Console messages would no longer appear in the terminal. This is because the hermes inspector overrides the console object with its own to intercept messages and send them to the debug client.
With this change I made it so that messages are sent to the original console as well instead of completely replacing it.
Changelog:
[General][Fixed] - When Hermes debugger is enabled continue to send log messages to the console
Reviewed By: mhorowitz
Differential Revision: D21509895
fbshipit-source-id: 6d91c4b82682e404679533be14b3e5f12e687e79
Summary:
This diff adds support for the "beforeScriptWithSourceMapExecution" instrumentation
breakpoint via "Debugger.setInstrumentationBreakpoint".
CDP describes it as a breakpoint, but we just set a flag in the inspector. A
fake breakpoint ID is synthesized for optional removal later.
Changelog: [Internal] Add Debugger.setInstrumentationBreakpoint to Hermes Inspector
Reviewed By: mhorowitz
Differential Revision: D21418218
fbshipit-source-id: 90fa49c0954980993815322d3a7effee416ed5db
Summary:
This removes the Hermes.setPauseOnLoad. It will be replaced by the more standard
Debugger.setInstrumentationBreakpoint's "beforeScriptExecution" event.
ChangeLog: [Internal] Remove Hermes.setPauseOnLoad message (to be replaced)
Reviewed By: mhorowitz
Differential Revision: D21418219
fbshipit-source-id: 93c53801c23487f9336b322c2bd737663ec21b97
Summary:
Move and create an empty rule that redirects as well, to handle //arvr rules
Need to do this way, since ovrsource sync rules are in different repo.
allow_many_files
allow-large-files
Steps:
- [X] Move glog from xplat/third-party to /third-party
- [ ] Update references in ovrsource to translate to //third-party instead of //xplat/third-party
- [ ] Get rid of temporary rule
- [ ] Update fbsource/third-party/glog to 0.3.5 (what we have in ovrsource)
Changelog: [Internal] Update reference for glog from xplat/third-party to /third-party.
Reviewed By: yfeldblum
Differential Revision: D21363584
fbshipit-source-id: c1ffe2dd615077170b03d98dcfb77121537793c9
Summary:
We are currently very strict about breakpoint location matching. This
diff allows some fuzz in the column, but not in the line.
Changelog: [Internal] Setting Hermes breakpoints no longer requires exact column match
Reviewed By: avp
Differential Revision: D21343198
fbshipit-source-id: a59786a9d63f9fe1ed576835ed660ba3343affe1
Summary:
This Hermes-specific mode is similar to Debugger.setPauseOnExceptions
and lets the VM know that it should enter a Pause state whenever a new
script is loaded/executed.
The debugger can then take its time to parse the source map and update
any breakpoints, before automatically continuing.
Changelog: [Internal] Implement a Hermes.setPauseOnLoad CDP call
Reviewed By: bestander
Differential Revision: D20754604
fbshipit-source-id: 7f9d0638706c99e9dcb534699b633f658e364909
Summary:
Until now we've generated scaffolding entirely based on the official devtools
protocol spec. This diff adds support for defining custom domains in `custom.json`
which will be merged with the upstream protocol JSON definition.
ChangeLog: [Internal] Add support for Hermes-specific CDP messages
Reviewed By: bestander
Differential Revision: D20754605
fbshipit-source-id: a8075f81816a40114d1a3332192c7aa076b17848
Summary:
This diff implements the instruction pointer save/restore trick Tzvetan came up with; allowing us to observe and modify the IP from outside the interpreter loop with negligible overhead.
From Tzvetan's internal post on the subject:
> [Today] the interpreter IP is just a local variable in the interpreter function, so there is no way to get to its value from outside the function. It lives in a register and we don't want to make it a Runtime field since the overhead [of accessing it via memory in the interpeter loop] would kill us.
> However, if you really think about it, it only lives in a register while the interpreter function is running. For the rest of the time, it is spilled by the C++ compiler onto the stack.
So, precisely when we need it, it is actually stored in memory. The only problem is, we don't know where! Admittedly, that is an annoying problem, but it feels like it should be solvable.
> What if, instead of relying on the compiler to spill the IP register, we manually spill it ourselves, to a known location? It works. Example: https://godbolt.org/z/ftSDnp
This diff implements this approach across the whole interpreter loop: whenever we call out of the loop we capture/publish the IP and restore it again immediately after the external call returns. This means we can now see the IP outside the interpret loop and even change it. This is effectively "for free" as the compiler now skips spilling/restoring the IP behind the scenes.
The immediate benefit of this is knowing the current IP allows us to have more accurate stack-traces during execution. In future this may enabled tricks like changing the IP before returning to the interpreter loop, allowing things outside the interpreter to affect program flow without adding logic to the interpreter loop.
Reviewed By: tmikov
Differential Revision: D20151091
fbshipit-source-id: 3814382639800208d8985a32ede31ba8f7ff7c80
Summary:
`fbsource//xplat` and `//xplat` are equivalent for FB BUCK targets. Removing extra prefix for consistency.
Changelog: [Internal]
Reviewed By: scottrice
Differential Revision: D20495655
fbshipit-source-id: a57b72f694c533e2e16dffe74eccb8fdec1f55f5
Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html
Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.
Reviewed By: zertosh
Differential Revision: D20636268
fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
Summary:
Changelog: [Internal]
Hermes inspector includes pthreads, arpa and sys headers on all OSes that would break vanilla Windows builds. This diff adds a check for posix-compliance before inclusion
(Note: this ignores all push blocking failures!)
Reviewed By: dulinriley
Differential Revision: D20564449
fbshipit-source-id: 8e264bc3104065dc4315bb291e8560609fe65184
Summary:
This adds support for 'returnByValue' in Runtime.evaluate invocations.
If the result of the evaluation can't be serialized to JSON, the results
are undefined.
ChangeLog: [Internal] - Hermes Inspector now supports 'returnByValue' in CDP Runtime.evaluate calls
[Facebook]
This is change was made to support debug completion in VSCode for ReactVR.
Reviewed By: ArchDev
Differential Revision: D19961115
fbshipit-source-id: d20af82b35d6bde88ab74b5c5a4c07415122c142
Summary:
Adding a `.clang-tidy` to a bunch of dirs under `react-native-github/ReactAndroid` and `react-native-github/ReactCommon`.
I don't want to add a single `.clang-tidy` at the root because we'll need more fine-grained control over what checks are enabled in different parts of the codebase; for example, fabric will and TM will probably have more checks enabled than older parts of the codebase that we're not actively modernizing, and the Hermes team probably wants its own config to be consistent with the rest of their codebase.
Starting off each `.clang-tidy` by only enabling clang-diagnostic; this is just to test that it's working. In the future, we'll work with the community to gradually enable more checks.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D19705749
fbshipit-source-id: 979cea053b645ac4a9790340033bfcfb49ca0f97
Summary:
Changelog: [Internal]
The inspector API doesn't really need a `HermesRuntime`, all it needs is a `jsi::Runtime` and a `Debugger &`.
Change the return type of `RuntimeAdapter::getRuntime` to be `jsi::Runtime`.
This will allow the inspector to use the tracing runtime instead of the direct hermes runtime.
Reviewed By: willholen
Differential Revision: D18973867
fbshipit-source-id: 6809e52452a35e62be9ca8143aeaba8964c98eaa
Summary:
This is an incomplete effort to migrate from libfb to libfbjni. This is needed to restore the compatibility with Flipper and other FB Android projects that make use of FBJNI. Effectively, the outcome is that `fbjni` no longer has a checked-in copy here, but instead relies on the public artifacts published at github.com/facebookincubator/fbjni that can be deduplicated at build-time.
**A non-exhaustive list of tasks:**
* [X] Gradle builds the SDK and RNTester for Android.
* [X] Buck build for rntester works in OSS.
* [ ] Move from `java-only` release to full `fbjni` release. This requires finding a solution for stripping out `.so` files that the old `Android.mk` insists on including in the final artifacts and will clash with the full distribution.
* [ ] Import this and fix potential internal build issues.
* [ ] Verify that the changes made to the Hermes integration don't have any unintended consequences.
## Changelog
[Android] [Changed] - Migrated from libfb to libfbjni for JNI calls
Pull Request resolved: https://github.com/facebook/react-native/pull/27729
Test Plan:
- CI is already passing again for Gradle and Buck in OSS.
- After applying the following patch, RNTester builds and works with the latest Flipper SDK:
```
diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle
index b8a6437d7..eac942104 100644
--- a/RNTester/android/app/build.gradle
+++ b/RNTester/android/app/build.gradle
@@ -170,10 +170,19 @@ dependencies {
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
- debugImplementation("com.facebook.flipper:flipper:0.23.4") {
+ debugImplementation("com.facebook.flipper🐬+") {
exclude group:'com.facebook.yoga'
- exclude group:'com.facebook.flipper', module: 'fbjni'
- exclude group:'com.facebook.litho', module: 'litho-annotations'
+ exclude group:'com.facebook.fbjni'
+ }
+
+ debugImplementation("com.facebook.flipper:flipper-network-plugin:+") {
+ exclude group:'com.facebook.yoga'
+ exclude group:'com.facebook.fbjni'
+ }
+
+ debugImplementation("com.facebook.flipper:flipper-fresco-plugin:+") {
+ exclude group:'com.facebook.yoga'
+ exclude group:'com.facebook.fbjni'
}
if (useIntlJsc) {
```
Reviewed By: mdvacca
Differential Revision: D19345270
Pulled By: passy
fbshipit-source-id: 33811e7f97f44f2ec5999e1c35339909dc4fd3b1
Summary:
Changelog: [Internal] Upgrade Chrome devtools protocol for Hermes
Update to the most recent version of the devtools protocol, r730699.
This just adds a few parameters to the stable API.
They have reasonable defaults that shouldn't break the existing functionality.
Reviewed By: willholen
Differential Revision: D19387559
fbshipit-source-id: 49d9ebf4a1a20f349ea6e46be6d5f36184ba8afb
Summary:
Changelog: [Internal]
Before, we were relying on checking out the `devtools-protocol` Github repo at a specific commit and
making special changes to the JSON file.
In order to make it easier to update, use the officially published npm package.
I found the closest package version that was published, but it had two differences:
* `Runtime.getHeapUsage` was either missing (in earlier versions) or experimental (in later versions)
* `isDefault` and `isPageContext` were removed. I'm not sure what these were used for anyway, the comment leads me to believe they're probably not necessary anymore
There were some customizations made previously to annotate `recursive` on some properties. The npm package doesn't set these,
so I wrote some checks to add it back in if it can be detected. This was mostly to handle one special case: `Runtime.StackTrace`.
The workaround seems to be fine for that case.
Reviewed By: willholen
Differential Revision: D19386890
fbshipit-source-id: db0d85f6bc71cba77ee67d85efe2f38376d7cc87
Summary:
Changelog: [Internal]
This separate `.flowconfig` file was causing versioning issues.
Delete it so that `msggen` can share the same flowconfig as the rest
of React Native.
Reviewed By: willholen
Differential Revision: D19413710
fbshipit-source-id: 748cb50a3151df1c67ee7176e57e259e48f50be7
Summary:
GitHub still marks some dependencies as vulnerable. Updating them.
Changelog: [Internal]
Reviewed By: avp
Differential Revision: D19183702
fbshipit-source-id: 9c9c815816c4fc591c77d811058234a63aeda727
Summary:
`msggen` has dependencies on some npm packages with vulnerabilities.
This diff updates the dependency list.
Changelog: [Internal]
Reviewed By: avp
Differential Revision: D19107926
fbshipit-source-id: 0526f6fe430c162322ec9ecb84f3d78604cd76bc
Summary:
Our current lazy compilation parent scope issue caused us to only have a
single lexical scope, which was taken to be the global scope. This
effectively hid all local variables. Additionally, the variables were
not marked as enumerable, so Chrome didn't show them.
As further improvements, 'this' is now included, and we more correctly
tag parent scopes as closures.
Changelog: [Internal]
Reviewed By: avp
Differential Revision: D18671527
fbshipit-source-id: cbbf9fbd319e433b9f681bd23e4ad7b4bb4a3d74
Summary:
Currently, if you try to inspect globals in the debugger and they have
properties that throw exceptions, the app redscreens. In particular,
inspecting any function triggers the bug because of `arguments` and
`caller`.
This diff catches the exception and shows a placeholder instead.
Changelog: [Internal]
Reviewed By: mhorowitz
Differential Revision: D18664765
fbshipit-source-id: 0c662f3d97b21a29c57a1dd724e63d17a3b4e263
Summary:
We are rolling out exact-by-default syntax to xplat/js.
I had to manually move around some comments to preserve proper placement.
Changelog: [Internal]
Reviewed By: jbrown215
Differential Revision: D18633611
fbshipit-source-id: 48f7468dcc55b1d00985419d035a61c6820b3abe
Summary:
Lint all files in the inspector and apply auto-fixes for licenses.
Changelog: [Internal]
Reviewed By: mhorowitz
Differential Revision: D18210914
fbshipit-source-id: 91c45d4b02a04e99dd32cf0be8771e327fe03660
Summary:
setBreakpoint differs from the existing setBreakpointByUrl in that you
can specify a scriptId directly. This was not really possible before
now, since scriptIds were mapped via filenames rather than to
RuntimeModules.
When (re)loading files with the same name, this call can be used to set
breakpoints in a specific one, rather than just the latest version.
Changelog: [Internal]
Reviewed By: bestander
Differential Revision: D18362054
fbshipit-source-id: 6ff1e736c79a4e75dc424316675d426ce9902f5f
Summary:
We were calling `sendErrorToClient` on error, but this function only
returns a closure that we threw away. Change to actually send an error
response.
Changelog: [Internal]
Reviewed By: bestander
Differential Revision: D18362055
fbshipit-source-id: 2ff1750ffd2c32a9291d3ed74fa0aaecd76c64c6
Summary:
When a filename (potentially with changes) is loaded multiple times, we keep
multiple instances around but fail to alert the attached debugger about this.
By coupling ScriptIDs to RuntimeModules rather than filenames, we can track
multiple instances of the same name instead.
Changelog: [Internal]
Reviewed By: bestander
Differential Revision: D18362052
fbshipit-source-id: 2147af32bc48c5fd2a2b080ea09dfa4133de7cf5
Summary:
There's some incompatibilities which need to be fixed for real,
but this is a temporary fix to make the build work again.
Changelog: [Internal]
Reviewed By: willholen
Differential Revision: D18364011
fbshipit-source-id: c168e6496a504f9b00da0b9d758c50e2c6f314a4
Summary:
`mem` package vulnerability found.
> In nodejs-mem before version 4.0.0 there is a memory leak due to old results not being removed from the cache despite reaching maxAge. Exploitation of this can lead to exhaustion of memory and subsequent denial of service.
ref: https://github.com/sindresorhus/mem/commit/da4e4398cb27b602de3bd55f746efa9b4a31702b
`relay-compiler` depends on that.
```
relay-compiler@6.0.0
└─┬ yargs@9.0.1
└─┬ os-locale@2.1.0
└── mem@1.1.0
```
Pull Request resolved: https://github.com/facebook/relay/pull/2934
Test Plan:
- Tested the Relay compiler briefly on the open source examples project, seems like yargs doesn't error
- `js1 build relay --project facebook`
- `js1 jest`
Reviewed By: alunyov
Differential Revision: D18397131
Pulled By: kassens
fbshipit-source-id: 8b7fc5e237c7b4ce14ff3809cdd59d243e7c4523
Summary:
The Android makefiles had hard-coded paths to hermes-engine, sometimes looking in `node_modules` and other times looking in `..`. This commit implements the Node module resolution algorithm (see common.mk), which handles both of these cases and also looks further up the root if necessary, handling the case when the `hermes-engine` npm package is hoisted.
This commit does three things:
- Defines `find-node-module` and uses it in the makefiles to find `hermes-engine`
- Removes the unused `/path/to/hermes-engine/include` paths since this directory does not exist and should be `/path/to/hermes-engine/android/include` (`android`)
- Moves the definition of `REACT_NATIVE` in the makefiles to the top. It was defined after every `$(CLEAR_VARS)` invocation but was not actually cleared anyway. `$(CLEAR_VARS)` resets only `LOCAL_*` variables in this list: https://android.googlesource.com/platform/build/+/7dc45a8/core/clear_vars.mk
## Changelog
[Internal] [Changed] - Android Makefiles look for hermes-engine using Node's module resolution algorithm
Pull Request resolved: https://github.com/facebook/react-native/pull/26820
Test Plan: Run `./gradlew :ReactAndroid:installArchives`, which requires the hermes-engine paths to be correct in order to find the headers.
Differential Revision: D17923671
Pulled By: cpojer
fbshipit-source-id: 9238b8718a94080db1abbba6375a6a1d484c871d
Summary:
Fix Android gradle build error for native debug build.
`NATIVE_BUILD_TYPE=Debug ./gradlew :ReactAndroid:installArchives`
The root cause is `folly::Future<bool>` not declared.
As we don't include true folly::Future implementation in OSS build but to use a forward declaration,
the fix is pretty much like to original declaration as `folly::Future<folly::Unit>`.
## Changelog
[Android] [Fixed] - Fix compile error for native debug build
This change could be ignored from changelog which is only for internal development.
Pull Request resolved: https://github.com/facebook/react-native/pull/26248
Test Plan: Makes sure `NATIVE_BUILD_TYPE=Debug ./gradlew :ReactAndroid:installArchives` build without errors.
Differential Revision: D17169696
Pulled By: mdvacca
fbshipit-source-id: 42e8b84b7ee0d1bd99d913702df98bc030965f63