Disable the watchdog thread on B2G for everything but browser processes

RESOLVED FIXED in mozilla25

Status

()

RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: bholley, Assigned: bholley)

Tracking

unspecified
mozilla25
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Assignee)

Description

5 years ago
Doug and I were just discussing this IRL.

Because the watchdog thread is per-process, our multiprocess makes watchdogs significantly more expensive, because we have N of them waking up once per second.

As it turns out, we totally ignore the watchdog thread for chrome JS on B2G:

http://mxr.mozilla.org/mozilla-central/source/b2g/app/b2g.js#176

This pref, however, doesn't disable the (expensive) Watchdog + OperationCallback machinery that delivers the DOMOperationCallback - it just ignores the callback when it arrives.

Given that the parent process in b2g should never be running content JS, it seems like we should just disable the watchdog thread entirely in that case.

Moreover, doug pointed out that we probably shouldn't be doing a slow script dialog for app processes either - if they become unresponsive, we should just kill them.

This doesn't change the situation for the browser app, where we probably really do want the slow script dialog. But it puts us in a much better place.

How can we detect in XPConnect initialization which of these many situations we're dealing with?
> Given that the parent process in b2g should never be running content JS, it seems like we should 
> just disable the watchdog thread entirely in that case.

This makes sense to me.

> Moreover, doug pointed out that we probably shouldn't be doing a slow script dialog for app 
> processes either - if they become unresponsive, we should just kill them.

We have to be careful how we define "unresponsive".  With our current definition, we get bug 870541, which is problematic.

OTOH suppose an app goes into an infinite loop and we don't have any "unresponsiveness" handling of it.  The user will notice that the app is looping and hit the home button.  But the app is still running!  Whenever the phone's CPU is on, that app will sit in the bg and suck up battery.

Slow-script killing of one form or another helps with this problem, but of course it doesn't solve the problem; the site can just use setTimeout().  Maybe we throttle setTimeout while it's in the bg, but that still doesn't solve the problem.  We probably should just be freezing these apps; give them zero cpu.

IOW, I think I'd support not having a watchdog for apps, because we really need a better solution to actually fix the problem.

> How can we detect in XPConnect initialization which of these many situations we're dealing with?

We probably just want to send the parameters down with the ContentChild initializer before ContentChild::InitXPCOM() is called by ContentProcess.cpp.  The SendGetProcessAttributes call in ContentChild::Init() may be early enough.
"the browser app" is an app that runs in the main process -- I think you want us to disable the watchdog for everything except browser tabs.
Summary: Disable the watchdog thread on B2G for everything but the browser app → Disable the watchdog thread on B2G for everything but browser processes
(Assignee)

Comment 3

5 years ago
(In reply to Justin Lebar [:jlebar] from comment #2)
> "the browser app" is an app that runs in the main process -- I think you
> want us to disable the watchdog for everything except browser tabs.

Oh, then in that case we can't disable the watchdog in the parent process then.
(Assignee)

Comment 4

5 years ago
(In reply to Bobby Holley (:bholley) from comment #3)
> (In reply to Justin Lebar [:jlebar] from comment #2)
> > "the browser app" is an app that runs in the main process -- I think you
> > want us to disable the watchdog for everything except browser tabs.
> 
> Oh, then in that case we can't disable the watchdog in the parent process
> then.

Nevermind - I was confused.
(Assignee)

Comment 5

5 years ago
(In reply to Justin Lebar [:jlebar] from comment #1)
> IOW, I think I'd support not having a watchdog for apps, because we really
> need a better solution to actually fix the problem.

Ok. But that better solution probably needs to come before we disable the watchdog, right?
> Ok. But that better solution probably needs to come before we disable the watchdog, right?

It's not clear to me that what we have now is better than no watchdog in apps.
(In reply to Justin Lebar [:jlebar] from comment #1)
> We probably should just be freezing these apps; give them zero cpu.

I filed bug 872177
(Assignee)

Comment 8

5 years ago
I ended up disabling the watchdog thread for b2g in bug 870043 part 6.
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Assignee: nobody → bobbyholley+bmo
Target Milestone: --- → mozilla25
You need to log in before you can comment on or make changes to this bug.