Closed
Bug 1220012
Opened 10 years ago
Closed 10 years ago
Leak nsPipe from GeckoDriver.mozBrowserClose
Categories
(Remote Protocol :: Marionette, defect, P2)
Remote Protocol
Marionette
Tracking
(firefox45 fixed, b2g-v2.2 affected, b2g-v2.5 fixed, b2g-master fixed)
RESOLVED
FIXED
mozilla45
People
(Reporter: ting, Unassigned)
References
Details
(Keywords: pi-marionette-server)
Attachments
(1 file)
4.15 KB,
patch
|
ato
:
review+
mpotharaju
:
approval‑mozilla‑b2g44+
|
Details | Diff | Splinter Review |
Two nsPipe are created for the input/ouput stream in MarionetteServer.onSocketAccepted(). After MarionetteServer.onConnectionClosed() gets called, the connection (Dispatcher) is still referenced by leaked GeckoDriver.mozBrowserClose.
Now mozBrowserClose is removed when enter GeckoDriver.receiveMessage(), but probably it should be cleared before running any command.
Reporter | ||
Comment 1•10 years ago
|
||
(In reply to Ting-Yu Chou [:ting] from comment #0)
> Now mozBrowserClose is removed when enter GeckoDriver.receiveMessage(), but
> probably it should be cleared before running any command.
Hmm, it should be all right to clear the mozBrowserClose in receiveMessage() as it will receive the command's respone/error message from listener. Am double checking.
Comment 2•10 years ago
|
||
(In reply to Ting-Yu Chou [:ting] from comment #1)
> Hmm, it should be all right to clear the mozBrowserClose in receiveMessage()
> as it will receive the command's respone/error message from listener. Am
> double checking.
Note that receiveMessage is only called when the listener sends a message back to the driver; not at any other time.
Reporter | ||
Comment 3•10 years ago
|
||
Listener does send message (Marionette:ok,error,done) back to the driver, just driver does not listen to it (bug 1107706 part 5 made the change).
I'd like to move the code removing mozBrowserClose from GeckoDriver.receiveMessage() to GeckoDriver.responseCompleted(). How do you think?
Flags: needinfo?(ato)
Reporter | ||
Comment 4•10 years ago
|
||
Maybe we should simply add the messages back, so driver will receive the them. GeckoDriver.responseCompleted() is not always called, e.g., when it's out of sync.
Reporter | ||
Comment 5•10 years ago
|
||
(In reply to Ting-Yu Chou [:ting] from comment #4)
> Maybe we should simply add the messages back, so driver will receive the
> them. GeckoDriver.responseCompleted() is not always called, e.g., when it's
> out of sync.
Correction: Maybe we should simply add the message listeners back, so driver will receive the messages.
Reporter | ||
Comment 6•10 years ago
|
||
Is now testing the patch on device, will check on Monday.
Reporter | ||
Comment 7•10 years ago
|
||
Comment on attachment 8681119 [details] [diff] [review]
patch v1
The leak is not observed after running ~1.5h MTBF with the patch.
Flags: needinfo?(ato)
Attachment #8681119 -
Flags: review?(ato)
Reporter | ||
Comment 8•10 years ago
|
||
(In reply to Ting-Yu Chou [:ting] from comment #7)
> Comment on attachment 8681119 [details] [diff] [review]
> patch v1
>
> The leak is not observed after running ~1.5h MTBF with the patch.
It's monday morning, and still don't see the leaks.
Updated•10 years ago
|
status-b2g-v2.2:
--- → affected
status-b2g-master:
--- → affected
OS: Unspecified → Gonk (Firefox OS)
Priority: -- → P2
Hardware: Unspecified → ARM
Comment 9•10 years ago
|
||
David and Andreas, please help to review patch in comment 7. Many thanks.
Flags: needinfo?(dburns)
Flags: needinfo?(ato)
Updated•10 years ago
|
Blocks: MTBF-Marionette
Comment 10•10 years ago
|
||
Sorry for my late response to this bug, but I've been travelling to Japan.
(In reply to Ting-Yu Chou [:ting] from comment #0)
> Two nsPipe are created for the input/ouput stream in
> MarionetteServer.onSocketAccepted(). After
> MarionetteServer.onConnectionClosed() gets called, the connection
> (Dispatcher) is still referenced by leaked GeckoDriver.mozBrowserClose.
>
> Now mozBrowserClose is removed when enter GeckoDriver.receiveMessage(), but
> probably it should be cleared before running any command.
Can you please help me understand what reference prevents the nsPipe from being cleaned up?
I get that Dispatcher gets an instance of DebuggerTransport, which in turn encapsulates the input and output streams. However, the Dispatcher isn't passed to GeckoDriver.
From what I can tell, MarionetteServer#onConnectionClosed attempts to clean up the Dispatcher by deleting its reference to it form MarionetteServer#conns:
delete this.conns[id];
Is what you're saying that as long as GeckoDriver keeps an active event listener, mozbrowserclose in this case, it will never be cleaned up? But how does GeckoDriver reference Dispatcher?
If we want to clean up the GeckoDriver#mozBrowserClose event listener when we close the connection (MarionetteServer#onConnectionClosed) I feel removing it in GeckoDriver#receiveMessage is the wrong solution. Wouldn't this be better suited for a shutdown/cleanup method in GeckoDriver that we call when we want to deconstruct Dispatcher from MarionetteServer?
Flags: needinfo?(dburns)
Flags: needinfo?(ato)
Updated•10 years ago
|
Flags: needinfo?(janus926)
Keywords: ateam-marionette-server
OS: Gonk (Firefox OS) → All
Hardware: ARM → All
Reporter | ||
Comment 11•10 years ago
|
||
(In reply to Andreas Tolfsen (:ato) from comment #10)
> Is what you're saying that as long as GeckoDriver keeps an active event
> listener, mozbrowserclose in this case, it will never be cleaned up? But
> how does GeckoDriver reference Dispatcher?
GeckoDriver.emulator.send references to Dispatcher.send, which keeps the Dispatcher instance alive and Dispatcher.conn points to the DebuggerTransport. Also GeckoDriver is leaked to window through mozbrowserclose event listener.
>
> If we want to clean up the GeckoDriver#mozBrowserClose event listener when
> we close the connection (MarionetteServer#onConnectionClosed) I feel
> removing it in GeckoDriver#receiveMessage is the wrong solution. Wouldn't
> this be better suited for a shutdown/cleanup method in GeckoDriver that we
> call when we want to deconstruct Dispatcher from MarionetteServer?
In that way, the listener could be added many times but remove just once. Note the listener is added for commands actionChain, multiAction, clickElement, and singleTap, that's why I remove it in GeckoDriver.receiveMessage when the command is done.
Flags: needinfo?(janus926)
Comment 12•10 years ago
|
||
(In reply to Ting-Yu Chou [:ting] from comment #11)
> In that way, the listener could be added many times but remove just once.
> Note the listener is added for commands actionChain, multiAction,
> clickElement, and singleTap, that's why I remove it in
> GeckoDriver.receiveMessage when the command is done.
I've gone over this three times, but I still don't get it. Why do we need to remove mozbrowserclose only when ok, done, or error comes back and not otherwise?
Reporter | ||
Comment 13•10 years ago
|
||
(In reply to Andreas Tolfsen (:ato) from comment #12)
> (In reply to Ting-Yu Chou [:ting] from comment #11)
> > In that way, the listener could be added many times but remove just once.
> > Note the listener is added for commands actionChain, multiAction,
> > clickElement, and singleTap, that's why I remove it in
> > GeckoDriver.receiveMessage when the command is done.
>
> I've gone over this three times, but I still don't get it. Why do we need
> to remove mozbrowserclose only when ok, done, or error comes back and not
> otherwise?
Because from what I can see, ok, done, or error denotes the command is finished. And the listener is added before doing the commands, so remove it when the command gets done. It's also OK if you think we should just roll back to the code before refactoring, which removes the listener whenever receives a message.
Comment 14•10 years ago
|
||
Comment on attachment 8681119 [details] [diff] [review]
patch v1
Review of attachment 8681119 [details] [diff] [review]:
-----------------------------------------------------------------
(In reply to Ting-Yu Chou [:ting] from comment #13)
> Because from what I can see, ok, done, or error denotes the command is
> finished. And the listener is added before doing the commands, so remove it
> when the command gets done.
OK, thanks for all the explanations.
This patch changes the mozBrowserClose check from being run on every message from the listener to only on ok, done, and error. Provided this is fine, I see no reason to integrate this patch as it is.
Attachment #8681119 -
Flags: review?(ato) → review+
Reporter | ||
Comment 15•10 years ago
|
||
Thanks for reviewing. Try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=8c1462d242e0
Reporter | ||
Updated•10 years ago
|
Keywords: checkin-needed
Updated•10 years ago
|
status-b2g-v2.5:
--- → affected
Comment 16•10 years ago
|
||
Keywords: checkin-needed
Comment 17•10 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Reporter | ||
Comment 18•10 years ago
|
||
Comment on attachment 8681119 [details] [diff] [review]
patch v1
NOTE: Please see https://wiki.mozilla.org/Release_Management/B2G_Landing to better understand the B2G approval process and landings.
[Approval Request Comment]
Bug caused by (feature/regressing bug #): 1107706
User impact if declined: memory leaks from using marionette
Testing completed: marionette unit tests on try
Risk to taking this patch (and alternatives if risky): low as it just removes listeners
String or UUID changes made by this patch: none
Attachment #8681119 -
Flags: approval‑mozilla‑b2g44?
Comment 19•10 years ago
|
||
Mahe, please help to approve this uplift request. Thanks.
Flags: needinfo?(mpotharaju)
Comment 20•10 years ago
|
||
Comment on attachment 8681119 [details] [diff] [review]
patch v1
Approved for 2.5 uplifts.
Thanks
Flags: needinfo?(mpotharaju)
Attachment #8681119 -
Flags: approval‑mozilla‑b2g44? → approval‑mozilla‑b2g44+
Comment 21•10 years ago
|
||
Updated•3 years ago
|
Product: Testing → Remote Protocol
You need to log in
before you can comment on or make changes to this bug.
Description
•