-
Notifications
You must be signed in to change notification settings - Fork 1k
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(android): remove stored references to bridge that holds it in memory #6448
Conversation
this.localUrl = bridge.getLocalUrl(); | ||
this.serverUrl = bridge.getServerUrl(); |
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.
replace storing the Bridge with storing the strings needed for getSanitizedDomain
@@ -31,8 +31,7 @@ private void http(final PluginCall call, final String httpMethod) { | |||
@Override | |||
public void run() { | |||
try { | |||
HttpRequestHandler.bridge = bridge; | |||
JSObject response = HttpRequestHandler.request(call, httpMethod); | |||
JSObject response = HttpRequestHandler.request(call, httpMethod, getBridge()); |
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.
Replace storing a static reference to the Bridge with passing an instance of the Bridge in to the request
call.
Storing references to the Bridge in static classes will hold views in memory outside of their lifecycle, because the Bridge has an activity/fragment variable to keep a reference to its view. This is more obvious in Portals apps where memory leaks were found:
After removing variables storing the Bridge on the
HttpRequestHandler
(a direct static reference) and on theCapacitorCookieManager
(stored by staticCookieHandler
reference by the system) this memory leak seems to be resolved.