Skip to content

Commit 2b992cb

Browse files
authored
Merge pull request #1513 from NativeScript/darind/inspector-worker-console
fix: console.log in worker should not crash app (#1511)
2 parents c2ee6e7 + 5dd2c9a commit 2b992cb

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

test-app/runtime/src/main/cpp/JsV8InspectorClient.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,11 @@ void JsV8InspectorClient::sendToFrontEndCallback(const v8::FunctionCallbackInfo<
233233
}
234234
}
235235

236-
void JsV8InspectorClient::consoleLogCallback(const string& message, const string& logLevel) {
236+
void JsV8InspectorClient::consoleLogCallback(Isolate* isolate, const string& message, const string& logLevel) {
237237
if (!inspectorIsConnected()) {
238238
return;
239239
}
240240

241-
auto isolate = Runtime::GetRuntime(0)->GetIsolate();
242241
auto stack = v8::StackTrace::CurrentStackTrace(isolate, 1, v8::StackTrace::StackTraceOptions::kDetailed);
243242

244243
auto frame = stack->GetFrame(isolate, 0);

test-app/runtime/src/main/cpp/JsV8InspectorClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class JsV8InspectorClient : V8InspectorClient, v8_inspector::V8Inspector::Channe
3333
void flushProtocolNotifications() override;
3434

3535
static void sendToFrontEndCallback(const v8::FunctionCallbackInfo<v8::Value>& args);
36-
static void consoleLogCallback(const std::string& message, const std::string& logLevel);
36+
static void consoleLogCallback(v8::Isolate* isolate, const std::string& message, const std::string& logLevel);
3737

3838
void runMessageLoopOnPause(int context_group_id) override;
3939
void quitMessageLoopOnPause() override;

test-app/runtime/src/main/cpp/console/Console.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void Console::sendToADBLogcat(const std::string& message, android_LogPriority lo
6969

7070
void Console::sendToDevToolsFrontEnd(v8::Isolate* isolate, const std::string& message, const std::string& logLevel) {
7171
if (m_callback != nullptr) {
72-
m_callback(message, logLevel);
72+
m_callback(isolate, message, logLevel);
7373
}
7474
}
7575

test-app/runtime/src/main/cpp/console/Console.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace tns {
1313

14-
typedef void (*ConsoleCallback)(const std::string& message, const std::string& logLevel);
14+
typedef void (*ConsoleCallback)(v8::Isolate* isolate, const std::string& message, const std::string& logLevel);
1515

1616
class Console {
1717
public:

0 commit comments

Comments
 (0)