Closed Bug 851721 Opened 12 years ago Closed 12 years ago

Do not receive xpcom-shutdown event when phone is powering off

Categories

(Firefox OS Graveyard :: General, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(blocking-b2g:tef+, firefox20 wontfix, firefox21 wontfix, firefox22 verified, b2g18 verified, b2g18-v1.0.0 wontfix, b2g18-v1.0.1 verified)

VERIFIED FIXED
B2G C4 (2jan on)
blocking-b2g tef+
Tracking Status
firefox20 --- wontfix
firefox21 --- wontfix
firefox22 --- verified
b2g18 --- verified
b2g18-v1.0.0 --- wontfix
b2g18-v1.0.1 --- verified

People

(Reporter: anshulj, Assigned: m1)

References

Details

Attachments

(1 file, 2 obsolete files)

When powering off the device we do not receive the xpcom-shutdown event in our XPCOM component. We need this event to run the shutdown sequence.
I was told that the xpcom-shutdown event isn't sent in release builds (of b2g)
(tef+, but not necessarily on making xpcom-shutdown event fire in release builds but on the more general problem of, "how can a live xpcom component get notified of a device powerdown/reboot request" with the Gonk backend. It looks like we could hack something into LinuxPower.cpp for Gonk but that feels like a last resort hack.)
blocking-b2g: tef? → tef+
I'm not sure if we can use xpcom from within hal/ but if we can you could send observer notifications from there.
Or if not from the hal, maybe the mozPower implementation could emit a notification?
(In reply to Michael Vines [:m1] [:evilmachines] from comment #4) > Or if not from the hal, maybe the mozPower implementation could emit a > notification? Sure. That looks trivial to add in dom/power/PowerManager.cpp
Kewl. I'll take a stab at this. Any preferences to what the event should be called? For our use case we don't need to distinguish between power-off and reboot but do we want to add this now just to be more general? Forgive my ignorance, are observer notifications synchronous?
Assignee: nobody → mvines
Ha, let's bikeshed the naming... I would do something like system-power-off and system-reboot (and yes, keep 2 different ones). Observer notifications are synchronous, so the notifyObservers() call only returns after all observers have run. This let us use them to inspect/modify http requests for instance.
Wow I was thinking of those exact event names too! dom/power/PowerManager.cpp looks like it runs in a content process, would an observer notification there make it up to the main processed? I'm guessing no, and if so then maybe dom/power/PowerManagerService.cpp is a better place for this?
We need these do happen in the parent indeed. Quickly reading the power manager code, I don't think it's remoted, but I can be very wrong.
All the parent/child communication is done in the hal/ code. Even PowerManagerService is not remoted.
Attached patch emits the two new events from PowerManagerService.cpp. While PowerManagerService isn't remoted, turns out that only the system app uses mozPower to shutdown/reboot so we're already in the main process. Not so future proof but solves the v1.0.1 need nicely and with low risk, and avoids adding a Gonk-only notification into LinuxPower.cpp.
Attachment #727332 - Flags: feedback?(kchen)
Attachment #727332 - Flags: feedback?(fabrice)
Comment on attachment 727332 [details] [diff] [review] Emit "system-reboot" and "system-power-off" events Review of attachment 727332 [details] [diff] [review]: ----------------------------------------------------------------- I'll defer to Kanru that knows this part of the code well. The power API is usable by any certified app so I'm not a big fan of having that not being properly remoted. ::: dom/power/PowerManagerService.cpp @@ +116,5 @@ > PowerManagerService::Reboot() > { > + nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService(); > + if (obsServ) > + obsServ->NotifyObservers(nullptr, "system-reboot", nullptr); I haven't checked in this file, but usually the code style is to use if () { } even for single liners. @@ +117,5 @@ > { > + nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService(); > + if (obsServ) > + obsServ->NotifyObservers(nullptr, "system-reboot", nullptr); > + nit: trailing ws
Attachment #727332 - Flags: feedback?(fabrice)
Would folks prefer to add this to hal/linux/LinuxPower.cpp?
Same stuff moved to LinuxPower.cpp.
Attachment #727332 - Attachment is obsolete: true
Attachment #727332 - Flags: feedback?(kchen)
Attachment #728597 - Flags: review?(kchen)
Attachment #728597 - Flags: review?(fabrice)
Attachment #728597 - Flags: review?(kchen) → review+
Same as patch 2 but in hg style. Carrying forward r+
Attachment #728597 - Attachment is obsolete: true
Attachment #728597 - Flags: review?(fabrice)
Attachment #728684 - Flags: review+
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → B2G C4 (2jan on)
Flags: in-moztrap-
Can you please provide steps to verify this fix - as we will blackbox test from the UI?
Anshul if you can Verify this bug out, it would be much appreciated.
Flags: needinfo?(anshulj)
Keywords: verifyme
I have already verified this bug.
Status: RESOLVED → VERIFIED
Flags: needinfo?(anshulj)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: