Closed Bug 1185701 Opened 9 years ago Closed 9 years ago

timezone does not automatically update after coming out of airplane mode

Categories

(Firefox OS Graveyard :: Gaia::Settings, defect, P2)

ARM
Gonk (Firefox OS)
defect

Tracking

(blocking-b2g:2.5+, b2g-master affected)

RESOLVED DUPLICATE of bug 1209892
blocking-b2g 2.5+
Tracking Status
b2g-master --- affected

People

(Reporter: nick, Assigned: freesamael)

References

Details

(Keywords: foxfood, verifyme)

When traveling, the time did not auto update after coming out of airplane mode like in iOS or Android.  This was surprising.  Note, in settings I have: 

Settings > Date & Time > Set Automatically

set.
I'm changing timezones next Monday, so I'll try to confirm this.
Flags: needinfo?(pdolanjski)
[Blocking Requested - why for this release]:

I also seemed to have hit this issue going from Eastern time to Pacific time.
blocking-b2g: --- → 2.5?
QA Whiteboard: [foxfood-triage]
Flags: needinfo?(pdolanjski)
Component: Gaia → Gaia::Settings
2.5+ed. Need timezone issues fixed
blocking-b2g: 2.5? → 2.5+
Airplane Mode is dealing in system/js/airplane_mode.js

Fire the 'moztimechange' event after airplane_mode disabled might solve this issue.

If not, we have find out if the time update is triggered in gecko.
Flags: needinfo?(timdream)
I found gecko does not check airplane mode stat. Wanna know who is more familiar with online time update part so we can identify the issue more quickly.
https://developer.mozilla.org/en-US/docs/Web/API/Time_and_Clock_API

If system did not received 'moztimechange' event, it means time is not changed.


Hsin-Yi could you help forward the issue to proper person?
Flags: needinfo?(timdream) → needinfo?(htsai)
Sounds like bug 1089494...

Hi Nick and Peter,

I need more information from you to clarify what the root cause ise.

- Basically, "timezone" change event is coming from carrier (NITZ), but not all carriers support that. "time" change event could come either from NITZ or NTP, while NTP needs to work upon data connection.[1] So, when you said timezone doesn't automatically update, how about "time"? Was time updated or not? And, did the phone have data connection (either mobile or wifi) at that time?

- Did you happen to keep "Settings > Date & Time" page open at anytime after the timezone was supposed to change, for example, after you arrived the trip destination? I was asking because it is known that that page may alter the system time based on mcc/mnc.[2]

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1089494#c35
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=1089494#c37
Flags: needinfo?(pdolanjski)
Flags: needinfo?(nick)
Flags: needinfo?(htsai)
See Also: → 1089494
Honestly, I can't remember the details.  Sorry.  Qawanted added to see if we can verify this somehow.
Flags: needinfo?(pdolanjski)
Keywords: qawanted
On Firefox OS we have only one option "Set automatically" which should update both date&time and time zone automatically. So far works correctly only date&time update function. Time zone doesn't change when a phone connects to a cellular network. I turned off "Set automatically" and then changed a time zone. After I switch back "Set automatically" to "On" the time zone remains the same. Date and time updating works fine.
For instance Android 5.1.1 has two separately options for automatic date&time and time zone update. 

This was verified on Flame 2.5 and Aries 2.5

Device: Aries 2.5
Build ID: 20150908152248
Gaia: b81185d30e548f782770b852473ffb53c641a490
Gecko: b23b2fa33a9dcda59dbbca1d157eca3c32c5b862
Gonk: 2916e2368074b5383c80bf5a0fba3fc83ba310bd
Version: 43.0a1 (2.5)
Firmware Version: D5803_23.1.A.1.28_NCB.ftf
User Agent: Mozilla/5.0 (Mobile; rv:43.0) Gecko/43.0 Firefox/43.0
---------------------------------------------------------------------

Device: Flame 2.5
Build ID: 20150909050641
Gaia: 60e212543329ee48f2921e0cd92aaca4b4ce2f6a
Gecko: dd9e40b4695909f1595814c0e79e4d55d73dc283
Gonk: c4779d6da0f85894b1f78f0351b43f2949e8decd
Version: 43.0a1 (2.5)
Firmware Version: v18D
User Agent: Mozilla/5.0 (Mobile; rv:43.0) Gecko/43.0 Firefox/43.0
QA Whiteboard: [foxfood-triage] → [foxfood-triage][QAnalyst-Triage?]
Flags: needinfo?(jmercado)
QA Whiteboard: [foxfood-triage][QAnalyst-Triage?] → [foxfood-triage][QAnalyst-Triage+]
Flags: needinfo?(jmercado)
Keywords: qawanted
(In reply to Hsin-Yi Tsai (OOO Sep. 4 ~ Sep. 20) [:hsinyi] from comment #7)
> So, when you said
> timezone doesn't automatically update, how about "time"? 

Neither updated.

> Was time updated or
> not?

The time was not updated.

>And, did the phone have data connection (either mobile or wifi) at that
> time?

I can't remember, but it should have.

> - Did you happen to keep "Settings > Date & Time" page open at anytime after
> the timezone was supposed to change, for example, after you arrived the trip
> destination?

Probably; when the time didn't auto update, I set it manually after a few minutes.  I don't kill apps after opening them, so unless there was a memory pressure event that killed it, it probably stayed open.
Flags: needinfo?(nick)
Hsin-Yi, could you help check if it does related to bug 1089494?
Flags: needinfo?(htsai)
(In reply to Fred Lin [:gasolin] from comment #11)
> Hsin-Yi, could you help check if it does related to bug 1089494?

Hi Fred, Samael will help investigate this first. Thank you!
Flags: needinfo?(htsai)
Depends on: 1209892
I'm noticing one specific bug in bionic libc related to this issue. However it doesn't seem to be the only problem, gaia time still incorrect with bionic fix.
Turns out the major reason is that the javascript function Date.toLocaleString() caches DateTimeFormat (which includes timezone), so it doens't reflect timezone changes correctly. The issue seems to happen on almost all platforms (OS X, Linux, etc). I found related bugs of JS engine at [1], [2], [3], and Firefox OS is another platform impacted.

In the meantime, the Date object itself is up-to-date if applied the bionic patch, so Date.toString() will show correct result after Bug 1209892 being fixed.

In order to display datetime in locale-specific format (for example, Arabic characters), gaia will need to wait until the JS engine issue being fixed.  

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=476419
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=1198543
[3] https://bugzilla.mozilla.org/show_bug.cgi?id=1147872
Ran into this again last week, noticed that after changing the timezone manually, a restart was needed for the time to be reflected correctly.  Nice find, Samael!
It looks the issue of Date.toLocaleString() wasn't actually due to the DateTimeFormat cache on Firefox OS. B2G implementation resets in-memory cache default timezone on each timezone change [1].

After digging deeper, it routes me back to Bionic again. 

The internal ICU library uses tzset() to detect timezone [2]. It's expected that "daylight", "timezone" and "tzname" variables are updated by tzset() [3], but tzcode doesn't handle in-memory state structures well, causing running processes getting incorrect (not just out-of-date) "timezone" value. The behavior seems inherits original IANA tzcode implementation, not Bionic specific.

I've updated the patch in Bug 1209892 to address this issue. More details will be updated there.

BTW, the reason that JS engine uses ICU's timezone instead of the offset comes with the Date object itself when invoking Date.toLocaleString() is because the standard provides no way to pass offset to a DateTimeFormat instance [4]:
> [[timeZone]] is either the String value "UTC" or undefined.
So the value of getTimezoneOffset() could be inconsistent with what toLocaleString() shows.

[1] https://github.com/mozilla/gecko-dev/blob/125759fa6979830194cb6c50b3752ae9ea164e2c/hal/Hal.cpp#L489
[2] https://github.com/mozilla/gecko-dev/blob/125759fa6979830194cb6c50b3752ae9ea164e2c/intl/icu/source/i18n/timezone.cpp#L462-L473
[3] http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
[4] http://www.ecma-international.org/ecma-402/1.0/#sec-12.4
Priority: -- → P2
See Also: → 1208808
Hi Samael, can you take this bug?
Flags: needinfo?(sawang)
(In reply to Ken Chang[:ken] from comment #17)
> Hi Samael, can you take this bug?

I'm working on the more specific Bug 1209892, which has been raised to P1 and set as a blocker of lots of bugs with similar description to this bug.

I expect the fix of Bug 1209892 should also close most of bugs it blocks, including this one, since most of them are duplicated. So I recommend we wait for the fix of 1209892, and then verify all the bugs it blocks. Most of them will be closed, and then we can work on the rest.
Flags: needinfo?(sawang)
Assignee: nobody → sawang
Samael, does this issue need any followup change after Bug 1209892 is landed?
Flags: needinfo?(sawang)
(In reply to Fred Lin [:gasolin] from comment #19)
> Samael, does this issue need any followup change after Bug 1209892 is landed?

I'm hoping someone to re-validate this traveling issue with the fix of bug 1209892 as I can't verify it by myself...
Flags: needinfo?(sawang)
Keywords: qawanted
I just tried on emulator. With airplane mode on and off, then update NITZ timezone using emulator console command, the displayed time is updated properly. I think this issue is fixed with bug 1209892.
I also verified that the issue is not reproducible with the latest gecko and gaia upon emulator.

I will close this bug by marking as duplicate of bug 1209892 but leave "verifyme" keyword to put this on QA's radar.
Status: NEW → RESOLVED
Closed: 9 years ago
Keywords: qawantedverifyme
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.