Open NathanWalker opened 4 years ago
This is the compiled js from the plugin regarding the problem area with GIDSignInDelegateImpl
:
var GIDSignInDelegateImpl = (function (_super) {
__extends(GIDSignInDelegateImpl, _super);
function GIDSignInDelegateImpl() {
return _super !== null && _super.apply(this, arguments) || this;
}
GIDSignInDelegateImpl.new = function () {
if (GIDSignInDelegateImpl.ObjCProtocols.length === 0 && typeof (GIDSignInDelegate) !== "undefined") {
GIDSignInDelegateImpl.ObjCProtocols.push(GIDSignInDelegate);
}
return _super.new.call(this);
};
GIDSignInDelegateImpl.prototype.initWithCallback = function (callback) {
this.callback = callback;
return this;
};
GIDSignInDelegateImpl.prototype.signInDidSignInForUserWithError = function (signIn, user, error) {
this.callback(user, error);
};
GIDSignInDelegateImpl.ObjCProtocols = [];
return GIDSignInDelegateImpl;
}(NSObject));
After debugging we have discovered that the issue is related to a javascript variable in the plugin that is used after being garbage collected: https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/src/firebase.ios.ts#L745
The fAuth
is a local variable that gets initialized to store a native counterpart is then used inside the GidSignInDelegate
callback: https://github.com/EddyVerbruggen/nativescript-plugin-firebase/blob/master/src/firebase.ios.ts#L984
To prevent this issue we need to fix the scope of this variable to ensure that it will not be eligible for GC before the delegate callback is invoked by some native code.
repro:
Just login via google with firebase plugin.
This works fine with JavaScriptCore ios-runtime.