-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[TIMOB-10093] Android: HTTPClient leaks function callbacks (ex: onload, ondatastream) #2687
Conversation
Exposes a direct method for calling a function referenced by an object property. Requires no additonal reference management since the object will retain the function for us. In most callback use cases this is okay and avoids circular reference bugs.
This wraps around KrollObject.callProperty() to make it async. and also thread safe.
A friendly reminder be sure to test on both V8 and Rhino. Also verify emulator and |
FR accepted. Huge improvement. Tested rhino+v8 on Galaxy Nexus (4.1) and HTC Desire (2.2), then also rhino+v8 on the 2.3 emulator. Makes me wish we didn't have event listener collections stored on the java side and could also just use methods-as-properties. But of course in the case of event listeners we need to support n listeners per event. :( CR almost okay, except our java standard wasn't followed with respect to function opening brace being on next line. This happened to me also recently because I was using Eclipse Juno and had forgotten to port the auto format settings over from Galileo. After those braces are fixed I'll accept. |
@billdawson I think all new code follows the Java coding standard plus a few tweaks documented in our wiki. While I don't have a preference either way, we should update the wiki if this is the practice we want to keep. |
On the topic of event listeners we do dispatch to the JS listeners with one native call (nativeFireEvent). |
Ah, okay. I just assumed it was in the standard because it has been our Yes, please change them, and I'll update the standard. On Wed, Aug 8, 2012 at 8:30 PM, Joshua Roesslein
|
per discussion, no change needed (it's not part of our standard, my bad.) CR also accepted. Merging... |
[TIMOB-10093] Android: HTTPClient leaks function callbacks (ex: onload, ondatastream)
This resolves a memory leak caused by the HTTPClient retaining a reference
to the JavaScript callback functions. The result would be a circular reference
of the HTTPClient (its retained by the callback function's scope).
I introduce a new API that allows calling properties on a proxy
object that are function from Java. This works around the circular reference issue
since it requires no extra referencing since the callbacks are kept alive anyway
since they are properties of the proxy.
See the JIRA ticket for a test case and instructions.