Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Run Connected Android Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 33
api-level: 35
target: google_apis
arch: x86_64
emulator-options: -no-snapshot -no-window -no-boot-anim -no-audio
Expand Down
20 changes: 15 additions & 5 deletions Core/AppRuntime/V8Inspector/Source/V8InspectorAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

#include <v8-inspector.h>
#include <v8-platform.h>
#if defined(__has_include) && __has_include(<v8-version.h>)
#include <v8-version.h>
#endif

#include <string.h>
#include <chrono>
Comment thread
matthargett marked this conversation as resolved.
Expand Down Expand Up @@ -194,7 +197,14 @@ namespace Babylon

void ConnectFrontend()
{
session_ = inspector_->connect(1, new ChannelImpl(agent_), v8_inspector::StringView(), v8_inspector::V8Inspector::kFullyTrusted);
#if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION >= 11)
session_ = inspector_->connect(
1, new ChannelImpl(agent_), v8_inspector::StringView(),
v8_inspector::V8Inspector::kFullyTrusted);
#else
session_ = inspector_->connect(
1, new ChannelImpl(agent_), v8_inspector::StringView());
#endif
Comment thread
matthargett marked this conversation as resolved.
}

void DisconnectFrontend()
Expand Down Expand Up @@ -419,9 +429,9 @@ namespace Babylon
}
v8::Local<v8::String> string_value = v8::Local<v8::String>::Cast(value);
int len = string_value->Length();
std::basic_string<char16_t> buffer(len, '\0');
string_value->Write(v8::Isolate::GetCurrent(), reinterpret_cast<uint16_t*>(&buffer[0]), 0, len); // Write expects uint16_t* but the template parameter is char16_t
return v8_inspector::StringBuffer::create(v8_inspector::StringView(reinterpret_cast<uint16_t*>(buffer.data()), len));
std::vector<uint16_t> buffer(len);
string_value->Write(v8::Isolate::GetCurrent(), buffer.data(), 0, len);
return v8_inspector::StringBuffer::create(v8_inspector::StringView(buffer.data(), len));
}

bool AgentImpl::AppendMessage(
Expand Down Expand Up @@ -661,4 +671,4 @@ namespace Babylon
return "file://" + script_path_;
}

} // namespace inspector
} // namespace inspector
2 changes: 1 addition & 1 deletion Core/Node-API/package-jsc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": {
"jsc-android": "250231.0.0"
"jsc-android": "294992.0.0"
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ npm install
_Follow the steps from [All Development Platforms](#all-development-platforms) before proceeding._

**Required Tools:**
[Android Studio](https://developer.android.com/studio), [Node.js](https://nodejs.org/en/download/), [Ninja](https://ninja-build.org/)
[Android Studio](https://developer.android.com/studio) with Android NDK 28.2.13676358 and API level 35 SDK platform installed, [Node.js](https://nodejs.org/en/download/), [Ninja](https://ninja-build.org/)

The minimal requirement target is Android 5.0.

Expand All @@ -42,7 +42,7 @@ An `.apk` that can be executed on your device or simulator is the output.

First, download the latest release of Ninja, extract the binary, and add it to your system path.

Once you have Android Studio downloaded, you need to set up an Android emulator if you do not have a physical Android device. You can do this by selecting `Tools` -> `Device Manager` and then selecting a device. (We are using Pixel 2 API 27).
Once you have Android Studio downloaded, you need to set up an Android emulator if you do not have a physical Android device. You can do this by selecting `Tools` -> `Device Manager` and then selecting a device. (We are using Pixel 2 API 35).

Open the project located at
`JsRuntimeHost\Tests\UnitTests\Android` with Android Studio. Note that this can take a while to load. (The bottom right corner of the Android Studio window shows you what is currently being loaded.)
Expand All @@ -68,4 +68,4 @@ Security Response Center (MSRC) at [secure@microsoft.com](mailto:secure@microsof
You should receive a response within 24 hours. If for some reason you do not, please
follow up via email to ensure we received your original message. Further information,
including the [MSRC PGP](https://technet.microsoft.com/en-us/security/dn606155) key, can
be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/default).
be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/default).
39 changes: 29 additions & 10 deletions Tests/UnitTests/Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,55 @@ if (project.hasProperty("jsEngine")) {
jsEngine = project.property("jsEngine")
}

def targetApiLevel = 35
def requiredNdkVersion = project.findProperty("ndkVersion") ?: "28.2.13676358"

android {
namespace 'com.jsruntimehost.unittests'
compileSdk 33
ndkVersion = "23.1.7779620"
if (project.hasProperty("ndkVersion")) {
ndkVersion = project.property("ndkVersion")
}
compileSdk targetApiLevel
ndkVersion = requiredNdkVersion

defaultConfig {
applicationId "com.jsruntimehost.unittests"
minSdk 21
targetSdk 33
targetSdk targetApiLevel
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

externalNativeBuild {
cmake {
arguments (
arguments(
"-DANDROID_STL=c++_shared",
"-DNAPI_JAVASCRIPT_ENGINE=${jsEngine}",
"-DJSRUNTIMEHOST_CORE_APPRUNTIME_V8_INSPECTOR=ON"
)
}
}

if (project.hasProperty("abiFilters")) {
ndk {
abiFilters project.getProperty("abiFilters")
ndk {
def abiFiltersProp = project.findProperty("abiFilters")?.toString()
if (abiFiltersProp) {
def propFilters = abiFiltersProp.split(',').collect { it.trim() }.findAll { !it.isEmpty() }
if (!propFilters.isEmpty()) {
abiFilters(*propFilters)
}
} else {
def requestedAbi = project.findProperty("android.injected.build.abi") ?: System.getenv("ANDROID_ABI")
def defaultAbis = []
if (requestedAbi) {
defaultAbis = requestedAbi.split(',').collect { it.trim() }.findAll { !it.isEmpty() }
}
if (defaultAbis.isEmpty()) {
def hostArch = (System.getProperty("os.arch") ?: "").toLowerCase()
if (hostArch.contains("aarch64") || hostArch.contains("arm64")) {
defaultAbis = ['arm64-v8a']
} else {
defaultAbis = ['arm64-v8a', 'x86_64']
}
}
abiFilters(*defaultAbis)
Comment thread
matthargett marked this conversation as resolved.
Comment thread
matthargett marked this conversation as resolved.
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion Tests/UnitTests/Android/app/src/main/cpp/JNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ Java_com_jsruntimehost_unittests_Native_javaScriptTests(JNIEnv* env, jclass claz
android::global::Initialize(javaVM, context);

Babylon::DebugTrace::EnableDebugTrace(true);
Babylon::DebugTrace::SetTraceOutput([](const char* trace) { printf("%s\n", trace); fflush(stdout); });
// Emit debug-trace lines straight to logcat under a dedicated "JsRuntimeHost" tag instead of
// routing them through AndroidExtensions' StdoutLogger (which forwards all stdout under a single
// tag, interleaved with the gtest output). The distinct tag keeps connected-test diagnostics
// filterable, e.g. `adb logcat -s JsRuntimeHost`.
Babylon::DebugTrace::SetTraceOutput([](const char* trace) { __android_log_print(ANDROID_LOG_INFO, "JsRuntimeHost", "%s", trace); });
Comment thread
matthargett marked this conversation as resolved.

auto testResult = RunTests();

Expand Down