Skip to content

Commit 68960b0

Browse files
author
Vasil Hristov
authored
Merge pull request #1516 from NativeScript/vmutafov/merge-release-into-master
Merge release into master
2 parents 597c14e + a5f9136 commit 68960b0

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
## What's New
55
- [Upgrade v8 to 7.7.299.11 (#1478)](https://github.com/NativeScript/android-runtime/issues/1478)
66

7+
6.1.2
8+
==
9+
10+
## Bug Fixes
11+
12+
- [UI freezes with tns-android 6.1.0 (Android only) (#1479)](https://github.com/NativeScript/android-runtime/issues/1479)
13+
14+
6.1.1
15+
==
16+
17+
## Bug Fixes
18+
19+
- [When using kotlin sometimes the metadata is not existing in the result apk (#1476)](https://github.com/NativeScript/android-runtime/issues/1476)
20+
21+
722
6.1.0
823
==
924

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ void ObjectManager::Init(Isolate *isolate) {
8585
m_poJsWrapperFunc = new Persistent<Function>(isolate, jsWrapperFunc);
8686

8787
if (m_markingMode != JavaScriptMarkingMode::None) {
88-
isolate->AddGCPrologueCallback(ObjectManager::OnGcStartedStatic, kGCTypeAll);
89-
isolate->AddGCEpilogueCallback(ObjectManager::OnGcFinishedStatic, kGCTypeAll);
88+
isolate->AddGCPrologueCallback(ObjectManager::OnGcStartedStatic, kGCTypeMarkSweepCompact);
89+
isolate->AddGCEpilogueCallback(ObjectManager::OnGcFinishedStatic, kGCTypeMarkSweepCompact);
9090
}
9191
}
9292

@@ -380,9 +380,18 @@ void ObjectManager::JSObjectWeakCallback(Isolate *isolate, ObjectWeakCallbackSta
380380
jsInstanceInfo->IsJavaObjectWeak = true;
381381
}
382382
} else {
383-
assert(!m_markedForGC.empty());
384-
auto &topGCInfo = m_markedForGC.top();
385-
topGCInfo.markedForGC.push_back(po);
383+
if(m_markedForGC.empty()){
384+
// Emulates the behavior in the OnGcStarted callback. Тhis is necessary as the hooking
385+
// to the V8 GC is done only on the markSweepCompact phase. The JSObjectWeakCallback
386+
// however is still triggered in other V8 GC phases (scavenger for example). This
387+
// creates a problem that there is no 'top' on the m_markedForGC stack.
388+
GarbageCollectionInfo gcInfo(++m_numberOfGC);
389+
gcInfo.markedForGC.push_back(po);
390+
m_markedForGC.push(gcInfo);
391+
} else {
392+
auto &topGCInfo = m_markedForGC.top();
393+
topGCInfo.markedForGC.push_back(po);
394+
}
386395
}
387396
}
388397
}
@@ -637,9 +646,15 @@ void ObjectManager::MarkReachableArrayElements(Local<Object> &o, stack<Local<Val
637646

638647
void ObjectManager::OnGcStartedStatic(Isolate *isolate, GCType type, GCCallbackFlags flags) {
639648
try {
649+
tns::instrumentation::Frame frame;
650+
640651
auto runtime = Runtime::GetRuntime(isolate);
641652
auto objectManager = runtime->GetObjectManager();
642653
objectManager->OnGcStarted(type, flags);
654+
655+
if(frame.check()){
656+
frame.log("OnGcStartedStatic");
657+
}
643658
} catch (NativeScriptException &e) {
644659
e.ReThrowToV8();
645660
} catch (std::exception e) {
@@ -655,9 +670,15 @@ void ObjectManager::OnGcStartedStatic(Isolate *isolate, GCType type, GCCallbackF
655670

656671
void ObjectManager::OnGcFinishedStatic(Isolate *isolate, GCType type, GCCallbackFlags flags) {
657672
try {
673+
tns::instrumentation::Frame frame;
674+
658675
auto runtime = Runtime::GetRuntime(isolate);
659676
auto objectManager = runtime->GetObjectManager();
660677
objectManager->OnGcFinished(type, flags);
678+
679+
if(frame.check()){
680+
frame.log("OnGcFinishedStatic");
681+
}
661682
} catch (NativeScriptException &e) {
662683
e.ReThrowToV8();
663684
} catch (std::exception e) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class ObjectManager {
7878
};
7979

8080
JavaScriptMarkingMode GetMarkingMode();
81+
8182
private:
8283

8384
struct JSInstanceInfo {
@@ -166,6 +167,8 @@ class ObjectManager {
166167

167168
static void JSObjectFinalizerStatic(const v8::WeakCallbackInfo<ObjectWeakCallbackState>& data);
168169

170+
171+
169172
void JSObjectWeakCallback(v8::Isolate* isolate, ObjectWeakCallbackState* callbackState);
170173

171174
void JSObjectFinalizer(v8::Isolate* isolate, ObjectWeakCallbackState* callbackState);

0 commit comments

Comments
 (0)