Skip to content

Commit 54b34e0

Browse files
authored
Revert "fix: prevent crash during debug on fast view churn (like with HMR) (#…"
This reverts commit 42a5328.
1 parent 17ed63a commit 54b34e0

File tree

1 file changed

+3
-39
lines changed

1 file changed

+3
-39
lines changed

NativeScript/runtime/ArgConverter.mm

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#include <Foundation/Foundation.h>
22
#include <sstream>
3-
#include <unordered_set>
43
#include "ArgConverter.h"
54
#include "NativeScriptException.h"
65
#include "DictionaryAdapter.h"
76
#include "ObjectManager.h"
87
#include "Interop.h"
98
#include "Helpers.h"
109
#include "Runtime.h"
11-
#include "RuntimeConfig.h"
1210

1311
using namespace v8;
1412
using namespace std;
@@ -29,27 +27,7 @@
2927
bool callSuper = false;
3028
if (instanceMethod) {
3129
BaseDataWrapper* wrapper = tns::GetValue(isolate, receiver);
32-
33-
if (wrapper == nullptr) {
34-
// During fast view churn like HMR in development, JS objects can outlive their
35-
// native wrappers briefly. In Debug, avoid a crash and just skip the native call.
36-
// In Release, assert so crash reporting can capture unexpected cases.
37-
if (RuntimeConfig.IsDebug) {
38-
const char* selectorStr = meta ? meta->selectorAsString() : "<unknown>";
39-
const char* jsNameStr = meta ? meta->jsName() : "<unknown>";
40-
const char* classNameStr = klass ? class_getName(klass) : "<unknown>";
41-
// Suppress duplicate logs: only log once per class+selector for this process.
42-
static std::unordered_set<std::string> s_logged;
43-
std::string key = std::string(classNameStr) + ":" + selectorStr;
44-
if (s_logged.insert(key).second) {
45-
Log(@"Note: ignore method on non-native receiver (class: %s, selector: %s, jsName: %s, args: %d). Common during HMR.",
46-
classNameStr, selectorStr, jsNameStr, (int)args.Length());
47-
}
48-
return v8::Undefined(isolate);
49-
} else {
50-
tns::Assert(false, isolate);
51-
}
52-
}
30+
tns::Assert(wrapper != nullptr, isolate);
5331

5432
if (wrapper->Type() == WrapperType::ObjCAllocObject) {
5533
ObjCAllocDataWrapper* allocWrapper = static_cast<ObjCAllocDataWrapper*>(wrapper);
@@ -65,21 +43,7 @@
6543
// For extended classes we will call the base method
6644
callSuper = isMethodCallback && it != cache->ClassPrototypes.end();
6745
} else {
68-
if (RuntimeConfig.IsDebug) {
69-
const char* selectorStr = meta ? meta->selectorAsString() : "<unknown>";
70-
const char* jsNameStr = meta ? meta->jsName() : "<unknown>";
71-
const char* classNameStr = klass ? class_getName(klass) : "<unknown>";
72-
// Suppress duplicate logs: only log once per class+selector for this process.
73-
static std::unordered_set<std::string> s_logged;
74-
std::string key = std::string(classNameStr) + ":" + selectorStr;
75-
if (s_logged.insert(key).second) {
76-
Log(@"Note: ignore receiver wrapper type %d (class: %s, selector: %s, jsName: %s). Common during HMR.",
77-
(int)wrapper->Type(), classNameStr, selectorStr, jsNameStr);
78-
}
79-
return v8::Undefined(isolate);
80-
} else {
81-
tns::Assert(false, isolate);
82-
}
46+
tns::Assert(false, isolate);
8347
}
8448
}
8549

@@ -914,7 +878,7 @@
914878
Local<Object> thiz = args.This();
915879
Isolate* isolate = args.GetIsolate();
916880
BaseDataWrapper* wrapper = tns::GetValue(isolate, thiz);
917-
if (wrapper == nullptr || wrapper->Type() != WrapperType::ObjCObject) {
881+
if (wrapper == nullptr && wrapper->Type() != WrapperType::ObjCObject) {
918882
return;
919883
}
920884

0 commit comments

Comments
 (0)