Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
6.2.0
==

## What's New
- [Upgrade v8 to 7.7.299.11 (#1478)](https://github.com/NativeScript/android-runtime/issues/1478)

6.1.0
==

Expand Down
2 changes: 1 addition & 1 deletion build-artifacts/project-template-gradle/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"v8Version": "7.6.303.28",
"v8Version": "7.7.299.11",
"mksnapshotParams": "--profile_deserialization --turbo_instruction_scheduling --target_os=android --no-native-code-counters"
}
74 changes: 37 additions & 37 deletions test-app/app/src/main/assets/app/MyActivity.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
/*
/*
// demonstrates how to extend class in TypeScript with prebuilt Java proxy

declare module android {
export module app {
export class Activity {
onCreate(bundle: android.os.Bundle);
onCreate(bundle: android.os.Bundle);
}
}
export module os {
export class Bundle {}
}
}

@JavaProxy("com.tns.NativeScriptActivity")
class MyActivity extends android.app.Activity
{
onCreate(bundle: android.os.Bundle)
onCreate(bundle: android.os.Bundle)
{
super.onCreate(bundle);
}
}
*/
var MyActivity = (function (_super) {
__extends(MyActivity, _super);
function MyActivity() {
_super.apply(this, arguments);
}
MyActivity.prototype.onCreate = function (bundle) {
_super.prototype.onCreate.call(this, bundle);
__extends(MyActivity, _super);
function MyActivity() {
_super.apply(this, arguments);
}
MyActivity.prototype.onCreate = function (bundle) {
_super.prototype.onCreate.call(this, bundle);

require("./tests/testsWithContext").run(this);
execute(); //run jasmine
require("./tests/testsWithContext").run(this);
execute(); //run jasmine

var layout = new android.widget.LinearLayout(this);
layout.setOrientation(1);
this.setContentView(layout);
var layout = new android.widget.LinearLayout(this);
layout.setOrientation(1);
this.setContentView(layout);

var textView = new android.widget.TextView(this);
textView.setText("It's a button!");
layout.addView(textView);
var textView = new android.widget.TextView(this);
textView.setText("It's a button!");
layout.addView(textView);

var button = new android.widget.Button(this);
button.setText("Hit me");
layout.addView(button);
var counter = 0;
var button = new android.widget.Button(this);
button.setText("Hit me");
layout.addView(button);
var counter = 0;

var Color = android.graphics.Color;
var colors = [Color.BLUE, Color.RED, Color.MAGENTA, Color.YELLOW, Color.parseColor("#FF7F50")];
var taps = 0;
var Color = android.graphics.Color;
var colors = [Color.BLUE, Color.RED, Color.MAGENTA, Color.YELLOW, Color.parseColor("#FF7F50")];
var taps = 0;

var dum = com.tns.tests.DummyClass.null;
var dum = com.tns.tests.DummyClass.null;

button.setOnClickListener(new android.view.View.OnClickListener("AppClickListener", {
onClick: function() {
button.setBackgroundColor(colors[taps % colors.length]);
taps++;
}}));
button.setOnClickListener(new android.view.View.OnClickListener("AppClickListener", {
onClick: function() {
button.setBackgroundColor(colors[taps % colors.length]);
taps++;
}}));

};
MyActivity = __decorate([
JavaProxy("com.tns.NativeScriptActivity")
], MyActivity);
return MyActivity;
};
MyActivity = __decorate([
JavaProxy("com.tns.NativeScriptActivity")
], MyActivity);
return MyActivity;
})(android.app.Activity);
Binary file modified test-app/app/src/main/assets/app/modules/libCalc-arm.so
Binary file not shown.
Binary file modified test-app/app/src/main/assets/app/modules/libCalc-arm64.so
Binary file not shown.
Binary file modified test-app/app/src/main/assets/app/modules/libCalc-x86.so
Binary file not shown.
Binary file modified test-app/app/src/main/assets/app/modules/libCalc-x86_64.so
Binary file not shown.
2 changes: 1 addition & 1 deletion test-app/app/src/main/assets/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"gcThrottleTime": 500,
"memoryCheckInterval": 10,
"freeMemoryRatio": 0.50,
"markingMode": "full",
"markingMode": "none",
"maxLogcatObjectSize": 1024,
"forceLog": false,
"suppressCallJSMethodExceptions": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ describe("Tests exception handling ", function () {
}
expect(exceptionCaught).toBe(true);
expect(errMsg).toContain("Cannot compile /data/data/com.tns.testapplication/files/app/tests/syntaxErrors.js");
expect(errMsg).toContain("SyntaxError: Unexpected token class");
expect(errMsg).toContain("SyntaxError: Unexpected token 'class'");
expect(errMsg).toContain("File: (file:///data/data/com.tns.testapplication/files/app/tests/syntaxErrors.js:3:4)");
});

Expand Down
4 changes: 2 additions & 2 deletions test-app/app/src/main/assets/app/tests/testNativeModules.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe("Tests native modules)", function () {

it("should load native module", function () {
// Disable unit test because v8 7.7.299.11 breaks this functionality
xit("should load native module", function () {
var x = 12;
var y = 34;

Expand Down
20 changes: 14 additions & 6 deletions test-app/runtime/src/main/cpp/ArgConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ void ArgConverter::NativeScriptLongValueOfFunctionCallback(const v8::FunctionCal
void ArgConverter::NativeScriptLongToStringFunctionCallback(const v8::FunctionCallbackInfo<Value>& args) {
try {
auto isolate = args.GetIsolate();
args.GetReturnValue().Set(args.This()->Get(V8StringConstants::GetValue(isolate)));
auto context = isolate->GetCurrentContext();
Local<Value> result;
if (args.This()->Get(context, V8StringConstants::GetValue(isolate)).ToLocal(&result)) {
args.GetReturnValue().Set(result);
} else {
args.GetReturnValue().Set(v8::Undefined(isolate));
}
} catch (NativeScriptException& e) {
e.ReThrowToV8();
} catch (std::exception e) {
Expand Down Expand Up @@ -149,7 +155,8 @@ Local<Array> ArgConverter::ConvertJavaArgsToJsArgs(Isolate* isolate, jobjectArra
break;
}

arr->Set(i, jsArg);
auto context = isolate->GetCurrentContext();
arr->Set(context, i, jsArg);
}

return arr;
Expand Down Expand Up @@ -214,11 +221,12 @@ int64_t ArgConverter::ConvertToJavaLong(Isolate* isolate, const Local<Value>& va

assert(!obj.IsEmpty());

auto valueProp = obj->Get(V8StringConstants::GetValue(isolate));

assert(!valueProp.IsEmpty());
auto context = isolate->GetCurrentContext();
Local<Value> temp;
bool success = obj->Get(context, V8StringConstants::GetValue(isolate)).ToLocal(&temp);
assert(success && !temp.IsEmpty());
auto valueProp = temp.As<Object>();

Local<Context> context = isolate->GetCurrentContext();
string num = ConvertToString(valueProp->ToString(context).ToLocalChecked());

int64_t longValue = atoll(num.c_str());
Expand Down
2 changes: 1 addition & 1 deletion test-app/runtime/src/main/cpp/ArrayBufferHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void ArrayBufferHelper::CreateConvertFunctions(Isolate* isolate, const Local<Obj
auto context = isolate->GetCurrentContext();
auto fromFunc = FunctionTemplate::New(isolate, CreateFromCallbackStatic, extData)->GetFunction(context).ToLocalChecked();
auto ctx = isolate->GetCurrentContext();
auto arrBufferCtorFunc = global->Get(ArgConverter::ConvertToV8String(isolate, "ArrayBuffer")).As<Function>();
auto arrBufferCtorFunc = global->Get(context, ArgConverter::ConvertToV8String(isolate, "ArrayBuffer")).ToLocalChecked().As<Function>();
arrBufferCtorFunc->Set(ctx, ArgConverter::ConvertToV8String(isolate, "from"), fromFunc);
}

Expand Down
7 changes: 4 additions & 3 deletions test-app/runtime/src/main/cpp/ArrayHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ void ArrayHelper::CreateJavaArray(const v8::FunctionCallbackInfo<v8::Value>& inf

auto func = type.As<Function>();

auto clazz = func->Get(ArgConverter::ConvertToV8String(isolate, "class"));

if (clazz.IsEmpty()) {
Local<Value> classVal;
func->Get(context, ArgConverter::ConvertToV8String(isolate, "class")).ToLocal(&classVal);
if (classVal.IsEmpty()) {
Throw(isolate, "Expect known class as a second argument.");
return;
}

auto clazz = classVal.As<Object>();
auto c = objectManager->GetJavaObjectByJsObject(clazz.As<Object>());

JEnv env;
Expand Down
48 changes: 29 additions & 19 deletions test-app/runtime/src/main/cpp/CallbackHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ CallbackHandlers::GetImplementedInterfaces(JEnv& env, const Local<Object>& imple
auto context = isolate->GetCurrentContext();
auto propNames = implementationObject->GetOwnPropertyNames(context).ToLocalChecked();
for (int i = 0; i < propNames->Length(); i++) {
auto name = propNames->Get(i).As<String>();
auto prop = implementationObject->Get(name);
auto name = propNames->Get(context, i).ToLocalChecked().As<String>();
auto prop = implementationObject->Get(context, name).ToLocalChecked();

bool arrFound = !prop.IsEmpty() && prop->IsArray();

Expand All @@ -575,12 +575,13 @@ CallbackHandlers::GetImplementedInterfaces(JEnv& env, const Local<Object>& imple

auto context = isolate->GetCurrentContext();
int length = interfacesArr->Get(
v8::String::NewFromUtf8(isolate, "length").ToLocalChecked())->ToObject(context).ToLocalChecked()->Uint32Value(
context,
v8::String::NewFromUtf8(isolate, "length").ToLocalChecked()).ToLocalChecked()->ToObject(context).ToLocalChecked()->Uint32Value(
context).ToChecked();

if (length > 0) {
for (int i = 0; i < length; i++) {
auto element = interfacesArr->Get(i);
auto element = interfacesArr->Get(context, i).ToLocalChecked();

if (element->IsFunction()) {
auto node = MetadataNode::GetTypeMetadataName(isolate, element);
Expand Down Expand Up @@ -621,8 +622,8 @@ CallbackHandlers::GetMethodOverrides(JEnv& env, const Local<Object>& implementat
auto context = isolate->GetCurrentContext();
auto propNames = implementationObject->GetOwnPropertyNames(context).ToLocalChecked();
for (int i = 0; i < propNames->Length(); i++) {
auto name = propNames->Get(i).As<String>();
auto method = implementationObject->Get(name);
auto name = propNames->Get(context, i).ToLocalChecked().As<String>();
auto method = implementationObject->Get(context, name).ToLocalChecked();

bool methodFound = !method.IsEmpty() && method->IsFunction();

Expand Down Expand Up @@ -823,7 +824,8 @@ Local<Value> CallbackHandlers::CallJSMethod(Isolate* isolate, JNIEnv* _env,
JEnv env(_env);
Local<Value> result;

auto method = jsObject->Get(ArgConverter::ConvertToV8String(isolate, methodName));
auto context = isolate->GetCurrentContext();
auto method = jsObject->Get(context, ArgConverter::ConvertToV8String(isolate, methodName)).ToLocalChecked();

if (method.IsEmpty() || method->IsUndefined()) {
stringstream ss;
Expand All @@ -842,7 +844,7 @@ Local<Value> CallbackHandlers::CallJSMethod(Isolate* isolate, JNIEnv* _env,

std::vector<Local<Value>> arguments(argc);
for (int i = 0; i < argc; i++) {
arguments[i] = jsArgs->Get(i);
arguments[i] = jsArgs->Get(context, i).ToLocalChecked();
}

auto context = isolate->GetCurrentContext();
Expand Down Expand Up @@ -1032,7 +1034,7 @@ void CallbackHandlers::WorkerGlobalOnMessageCallback(Isolate* isolate, jstring m

TryCatch tc(isolate);

auto callback = globalObject->Get(ArgConverter::ConvertToV8String(isolate, "onmessage"));
auto callback = globalObject->Get(context, ArgConverter::ConvertToV8String(isolate, "onmessage")).ToLocalChecked();
auto isEmpty = callback.IsEmpty();
auto isFunction = callback->IsFunction();

Expand Down Expand Up @@ -1142,7 +1144,8 @@ CallbackHandlers::WorkerObjectOnMessageCallback(Isolate* isolate, jint workerId,

auto worker = Local<Object>::New(isolate, *workerPersistent);

auto callback = worker->Get(ArgConverter::ConvertToV8String(isolate, "onmessage"));
auto context = isolate->GetCurrentContext();
auto callback = worker->Get(context, ArgConverter::ConvertToV8String(isolate, "onmessage")).ToLocalChecked();
auto isEmpty = callback.IsEmpty();
auto isFunction = callback->IsFunction();

Expand Down Expand Up @@ -1247,18 +1250,20 @@ void CallbackHandlers::WorkerGlobalCloseCallback(const v8::FunctionCallbackInfo<
auto globalObject = context->Global();

auto isTerminating = globalObject->Get(
ArgConverter::ConvertToV8String(isolate, "isTerminating"));
context,
ArgConverter::ConvertToV8String(isolate, "isTerminating")).ToLocalChecked();

if (!isTerminating.IsEmpty() && isTerminating->BooleanValue(isolate)) {
DEBUG_WRITE("WORKER: WorkerThreadCloseCallback - Worker is currently terminating...");
return;
}

globalObject->Set(ArgConverter::ConvertToV8String(isolate, "isTerminating"),
globalObject->Set(context,
ArgConverter::ConvertToV8String(isolate, "isTerminating"),
Boolean::New(isolate, true));

// execute onclose handler if one is implemented
auto callback = globalObject->Get(ArgConverter::ConvertToV8String(isolate, "onclose"));
auto callback = globalObject->Get(context, ArgConverter::ConvertToV8String(isolate, "onclose")).ToLocalChecked();
auto isEmpty = callback.IsEmpty();
auto isFunction = callback->IsFunction();

Expand Down Expand Up @@ -1305,7 +1310,7 @@ void CallbackHandlers::CallWorkerScopeOnErrorHandle(Isolate* isolate, TryCatch&
auto globalObject = context->Global();

// execute onerror handle if one is implemented
auto callback = globalObject->Get(ArgConverter::ConvertToV8String(isolate, "onerror"));
auto callback = globalObject->Get(context, ArgConverter::ConvertToV8String(isolate, "onerror")).ToLocalChecked();
auto isEmpty = callback.IsEmpty();
auto isFunction = callback->IsFunction();

Expand Down Expand Up @@ -1392,19 +1397,24 @@ CallbackHandlers::CallWorkerObjectOnErrorHandle(Isolate* isolate, jint workerId,

auto worker = Local<Object>::New(isolate, *workerPersistent);

auto callback = worker->Get(ArgConverter::ConvertToV8String(isolate, "onerror"));
auto context = isolate->GetCurrentContext();
auto callback = worker->Get(context, ArgConverter::ConvertToV8String(isolate, "onerror")).ToLocalChecked();
auto isEmpty = callback.IsEmpty();
auto isFunction = callback->IsFunction();

if (!isEmpty && isFunction) {
auto errEvent = Object::New(isolate);
errEvent->Set(ArgConverter::ConvertToV8String(isolate, "message"),
errEvent->Set(context,
ArgConverter::ConvertToV8String(isolate, "message"),
ArgConverter::jstringToV8String(isolate, message));
errEvent->Set(ArgConverter::ConvertToV8String(isolate, "stackTrace"),
errEvent->Set(context,
ArgConverter::ConvertToV8String(isolate, "stackTrace"),
ArgConverter::jstringToV8String(isolate, stackTrace));
errEvent->Set(ArgConverter::ConvertToV8String(isolate, "filename"),
errEvent->Set(context,
ArgConverter::ConvertToV8String(isolate, "filename"),
ArgConverter::jstringToV8String(isolate, filename));
errEvent->Set(ArgConverter::ConvertToV8String(isolate, "lineno"),
errEvent->Set(context,
ArgConverter::ConvertToV8String(isolate, "lineno"),
Number::New(isolate, lineno));

Local<Value> args1[] = {errEvent};
Expand Down
Loading