New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ios): maintain native module proxies #10855
Conversation
@garymathews I tried to run an app using sdk created with this code. It is giving following error - ` |
@vijaysingh-axway Looks like that's to do with Babel |
@garymathews But without this change it is working fine. |
@vijaysingh-axway Try it with the latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR passed.
Is this save to be cherry picked? I'm not sure if this may cause a memory leak at some point. Protecting and unprotecting JSCore references is a pretty sensitive topic. |
Backported it to 8_0_X. PR |
@@ -21,6 +21,9 @@ - (void)unregisterForNotifications | |||
|
|||
- (void)dealloc | |||
{ | |||
// Allow JavascriptCore to release module proxy. | |||
[self forgetSelf]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will never get called. A module/proxy only get's deallocated when JSCore will finalize a JSValueRef (i.e. when it's getting GC'd) and you actively prevent that by protecting the JSValueRef via rememberSelf
. Basically the dealloc chain is: KrollFinalizer
(triggered by JSCore GC) -> KrollObject
dealloc -> TiProxy
dealloc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since all native modules will be cached until the KrollBridge shuts down anyway it should be ok to remove the above lines and just stick with the rememberSelf
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to keep the forgetSelf
in dealloc
since it could be possible to call dealloc
on the KrollObject and there's no harm in keeping it it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You never send a dealloc
manually, it will be done automatically though retain/release. And since the JS object retains the KrollObject there is no way that it will be called in a way that makes sense.
Sure there is no harm in keeping it, but i would prefer not having code around that has no effect ;)
Keeping forgetSelf
in dealloc
Not able to test the master PR due to https://jira.appcelerator.org/browse/TIMOB-27040. Will check it once its fixed. |
FR Passed. Studio Ver: 5.1.2.201903111843 |
Fixes TIMOB-26985
TEST CASE
1.0.1
alloy.js
JIRA Ticket