Comments (9)
I am sorry, can you please provide a minimal reproduction of the problem using the Hermes CLI?
from hermes.
I am sorry, can you please provide a minimal reproduction of the problem using the Hermes CLI?
The same code executed directly by the hermes command on a mac is fine, but the results of a jsi call on android are not as expected
(modify /HermesTest/src/main/assets/test.js JsNativeLog(msg);=>print(msg); test.js can be executed directly with the hermes command)
from hermes.
I am sorry, can you please provide a minimal reproduction of the problem using the Hermes CLI?
The logic of executing js is very simple, just inject a JsNativeLog method to print the log, and then execute test.js
all code is in https://github.com/cs-robert/hermesTest
`
Java_com_example_hermestest_MainActivity_evaluateJavaScript(JNIEnv *env, jclass clazz,
jstring script) {
try {
std::shared_ptrfacebook::hermes::HermesRuntime runtime = facebook::hermes::makeHermesRuntime();
runtime->global().setProperty(*runtime, "JsNativeLog", facebook::jsi::Function::createFromHostFunction(
*runtime,
facebook::jsi::PropNameID::forAscii(*runtime, "JsNativeLog"),
0,
[](facebook::jsi::Runtime &rt,
const facebook::jsi::Value &thisVal,
const facebook::jsi::Value *arguments,
size_t argumentCount) {
auto str = arguments[0].getString(rt).utf8(rt);
__android_log_print(ANDROID_LOG_INFO, "JsNativeLog", "JSLog %s", str.c_str());
return facebook::jsi::Value();
}));
const char *scriptChar = env->GetStringUTFChars(script, nullptr);
std::string source = std::string(scriptChar);
std::shared_ptr hbcPtr = std::make_uniquefacebook::jsi::StringBuffer(source);
runtime->evaluateJavaScript(hbcPtr, "test.js");
} catch (const facebook::jsi::JSError &error) {
__android_log_print(ANDROID_LOG_ERROR, "JsNativeLog", "%s %s", error.getMessage().c_str(), error.getStack().c_str());
} catch (const facebook::jsi::JSIException &err) {
__android_log_print(ANDROID_LOG_ERROR, "JsNativeLog", "%s", err.what());
} catch (const std::exception &ex) {
__android_log_print(ANDROID_LOG_ERROR, "JsNativeLog", "%s", ex.what());
} catch (...) {
}
}
`
from hermes.
I am sorry, can you please provide a minimal reproduction of the problem using the Hermes CLI?
Strangely enough, when I delete some of the WebPack-generated code in the js file, it works fine.What I'm removing is a closure that won't execute and doesn't affect the logic。
my_engineGlobal, my_engineGlobal2, my_engineGlobal3, my_engineGlobal4... These variables are simply defined and printed in a method without any logic to modify them
from hermes.
from hermes.
hbc doesn't seem to have this problem, not sure if it's a coincidence or really OK
from hermes.
@cs-robert in your first post you said Hermes version 0.6.0. That version is almost 4 years old. Can you reproduce this with the latest Hermes version?
from hermes.
@cs-robert in your first post you said Hermes version 0.6.0. That version is almost 4 years old. Can you reproduce this with the latest Hermes version?
@tmikov 0.7.2 work fine,Why is hbc OK? And want to understand the specific logic of what caused it? How was it repaired?
from hermes.
@cs-robert it is hard to say, many things have changed in 4 years. Still, resolution of variables is very important, so I am pretty sure that even old versions didn't have major bugs related to it. You might be seeing a problem related to lazy compilation in an unexpected context: when running from source, Hermes lazily compiles every function when it is called the first time, which is a complicated process.
from hermes.
Related Issues (20)
- I hope Static Hermes supported Windows, Linux, and MacOS. HOT 2
- Local debug and release build throws a type error HOT 3
- I hope it was possible for Static Hermes to native AOT compile all the existing NPM modules. HOT 1
- Intl.DateTimeFormat does not support 'Europe/Kyiv' timezone HOT 2
- It would be good for Static Hermes if it could use pure JavaScript code(that has no type annotations) with automatic type guessing like "var" code in Dart, or ":=" in Go. HOT 7
- Using Intl with standalone Hermes app HOT 2
- Support for top level await HOT 1
- iphoneos framework very large size issue (build-apple-framework.sh) HOT 5
- [Debugger] Incorrect scope variable information for variable initialized in for-loop HOT 3
- Race Condition between HadesGC and HermesInternal.getEpilogues() Causes Segfault
- Assertion `IDom && "Reached the top of the tree!"' failed in ./hermes/lib/Optimizer/Scalar/Mem2Reg.cpp HOT 1
- prettier plugin: Infinite loop for malformed graphql relay query
- [Profiler] First sample sometimes has timestamp of zero HOT 1
- The Code Sentry scan reports code vulnerabilities - facebook/hermes HOT 2
- Short-hand methods don't have prototype / construct HOT 8
- Linking static hermes HOT 4
- spread arguments throw "constructor not callable" when `Array` variable declared HOT 1
- `atob` is less forgiving with padding than JSC, Node and browser based implementations HOT 3
- Partial async generator support persent in Hermes isn't spec compliant HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hermes.