Skip to content

Commit

Permalink
fix(ios): remove additional gc protection once proxy is remembered (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
janvennemann authored and lokeshchdhry committed Oct 14, 2019
1 parent a341c1b commit dfd5a02
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions iphone/Classes/TiAppiOSProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
@property (nonatomic, readonly) NSString *EVENT_ACCESSIBILITY_LAYOUT_CHANGED;
@property (nonatomic, readonly) NSString *EVENT_ACCESSIBILITY_SCREEN_CHANGED;

#ifdef DEBUG
- (void)garbageCollectForDebugging:(id)args;
#endif

@end

#endif
9 changes: 9 additions & 0 deletions iphone/Classes/TiAppiOSProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -1541,6 +1541,15 @@ - (NSString *)applicationOpenSettingsURL
return UIApplicationOpenSettingsURLString;
}

#ifdef DEBUG
JS_EXPORT void JSSynchronousGarbageCollectForDebugging(JSContextRef ctx);

- (void)garbageCollectForDebugging:(id)args
{
JSSynchronousGarbageCollectForDebugging(self.pageContext.krollContext.context);
}
#endif

MAKE_SYSTEM_STR(EVENT_ACCESSIBILITY_LAYOUT_CHANGED, @"accessibilitylayoutchanged");
MAKE_SYSTEM_STR(EVENT_ACCESSIBILITY_SCREEN_CHANGED, @"accessibilityscreenchanged");

Expand Down
10 changes: 8 additions & 2 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,12 @@ - (void)rememberProxy:(TiProxy *)rememberedProxy
if ((bridgeCount == 1) && (pageKrollObject != nil)) {
if (rememberedProxy == self) {
[pageKrollObject protectJsobject];
[pageKrollObject removeGarbageCollectionSafeguard];
return;
}
[pageKrollObject noteKeylessKrollObject:[rememberedProxy krollObjectForBridge:(KrollBridge *)pageContext]];
KrollObject *krollObject = [rememberedProxy krollObjectForBridge:(KrollBridge *)pageContext];
[pageKrollObject noteKeylessKrollObject:krollObject];
[krollObject removeGarbageCollectionSafeguard];
return;
}
if (bridgeCount < 1) {
Expand All @@ -652,13 +655,16 @@ - (void)rememberProxy:(TiProxy *)rememberedProxy
if (rememberedProxy == self) {
KrollObject *thisObject = [thisBridge krollObjectForProxy:self];
[thisObject protectJsobject];
[thisObject removeGarbageCollectionSafeguard];
continue;
}

if (![thisBridge usesProxy:rememberedProxy]) {
continue;
}
[[thisBridge krollObjectForProxy:self] noteKeylessKrollObject:[thisBridge krollObjectForProxy:rememberedProxy]];
KrollObject *krollObject = [thisBridge krollObjectForProxy:rememberedProxy];
[[thisBridge krollObjectForProxy:self] noteKeylessKrollObject:krollObject];
[krollObject removeGarbageCollectionSafeguard];
}
}

Expand Down

0 comments on commit dfd5a02

Please sign in to comment.