Bug 31432 - TimeZoneNotFoundException
Summary: TimeZoneNotFoundException
Status: RESOLVED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 5.1
Hardware: PC Windows
: Normal normal
Target Milestone: C6SR1
Assignee: marcos.henrich
URL:
Depends on:
Blocks:
 
Reported: 2015-06-27 08:35 UTC by Adam Kapos
Modified: 2016-09-17 22:27 UTC (History)
11 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Dump from device failing With TimeZoneNotFoundException (20.84 KB, text/plain)
2015-10-16 10:06 UTC, Rulon
Details
output of the updated script (65.48 KB, text/plain)
2015-10-30 09:40 UTC, Rulon
Details

Description Adam Kapos 2015-06-27 08:35:12 UTC
We have received reports of the following exception from our users:

Exception of type 'System.TimeZoneNotFoundException' was thrown.
 at System.TimeZoneInfo.get_Local () <0x000a4>
 at System.TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc (System.DateTime,bool&) <0x0002b>
 at System.DateTime.get_Now () <0x0006f>
 at OpenTK.Platform.Android.AndroidGameView.RunIteration (System.Threading.CancellationToken) <0x0007f>
 at OpenTK.Platform.Android.AndroidGameView/<StartThread>c__AnonStorey0.<>m__0 (object) <0x00027>
 at Android.App.SyncContext/<Send>c__AnonStorey1.<>m__0 () <0x00023>
 at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f>
 at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x0003b>

GMT+03:00, Moscow time

Devices:
Meizu m1 note running 4.4.4 
highscreen Zera F running 4.4.2 

Xamarin version:
Xamarin   3.11.590.0 (5160db7)
Xamarin.Android   5.1.3.1 (d419c934e6ce2113653ff4c40214e3a5d5a69440)
Comment 1 Ram Chandra 2015-06-30 13:21:13 UTC
I can't reproduce this, we may have to see if a developer can figure out what's going on from the stack trace. If you have a chance, it might also be helpful to include Application output, IDE logs , and device logs.

You can get IDE logs from here:
Visual Studio=> Help=> Xamarin => Zip Xamarin Logs ( attache the zip file)

You can get ADB logs from here:
Open Command prompt and navigate to Android SDK=> platform-tools directory and run the following command.
> adb logcat 

Environment Info:

Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.51641
Installed Version: Professional
Xamarin   3.11.590.0 (5160db7)
Xamarin.Android   5.1.3.1 (d419c934e6ce2113653ff4c40214e3a5d5a69440)
Xamarin.Forms Intellisense   1.0
Xamarin.iOS   8.10.1.0 (fce006eae308515fc1eaf85fcc0f90699d9c7e8b)
Comment 2 Adam Kapos 2015-07-02 05:26:00 UTC
I wasn't able to reproduce the issue on my own device, hence I cannot provide additional information.
Comment 3 Jonathan Pryor 2015-07-06 17:09:37 UTC
My best guess is that on those platforms java.util.TimeZone.getDefault().getID() is returning null or the empty string...which makes no sense.
Comment 4 Rulon 2015-08-05 09:07:19 UTC
I catch TimeZoneNotFoundException every time when call DateTime.Now(). 
It's often reproduces on Lenovo phones when timezone "GMT +03:00 Moscow" is selected.

Workaround for it is using DateTime.UtcNow.AddHours(3). But I can't use this when i try to create any system class if it use DateTime.Now() in constructor. An example, System.Net.Cookie throws TimeZoneNotFoundException when I try to create new instance.

This error throws in all versions of Xamarin.Android since v4.20.0.28
Comment 5 anemtsev 2015-08-21 05:56:19 UTC
Exception of type 'System.TimeZoneNotFoundException' was thrown. at System.TimeZoneInfo.get_Local () <0x000ac>
at System.TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc (System.DateTime,bool&) <0x0002b>
at System.DateTime.get_Now () <0x0006f>
at System.DateTime.get_Today ()

Devices:
Meizu MX4 Pro 
Jiayu G5S

Environment Info:
Xamarin Studio 5.9.5 (build 9)
MonoAndroid.dll 5.1.3.261654298

Looks like this bug appears only at phones which runs internally in UTC timezone.
Comment 6 anemtsev 2015-09-08 04:20:11 UTC
More info about devices, affected by this bug (Exception of type 'System.TimeZoneNotFoundException' was thrown.:   at System.TimeZoneInfo.get_Local () [0x00000] in <filename unknown>:0):

Lenovo A319
Lenovo A606
ZTE Blade V2 Lite
Comment 7 manuel 2015-09-17 06:51:32 UTC
Guys

we are experiencing this also with iOS. Although we are not able to reproduce it, we have it logged in our analytics system, which means it is happening with real users with the app crashing as soon as it is launched

Stack trace

System.TimeZoneNotFoundException: Exception of type 'System.TimeZoneNotFoundException' was thrown. at System.TimeZoneInfo.GetMonoTouchData (System.String name, Boolean throw_on_error) [0x00000] in <filename unknown>:0 at System.TimeZoneInfo.CreateLocal () [0x00000] in <filename unknown>:0 at System.TimeZoneInfo.get_Local () [0x00000] in <filename unknown>:0 at System.TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc (DateTime time, System.Boolean& isAmbiguousLocalDst) [0x00000] in <filename unknown>:0 at System.DateTime.get_Now () [0x00000] in <filename unknown>:0 at System.DateTime.get_Today () [0x00000] 

Mono and Frameworks used to compile the application

=== Xamarin Studio ===

Version 5.9.5 (build 10)
Installation UUID: 5f421f3f-40c4-4caa-8ae3-df7a8094edf4
Runtime:
	Mono 4.0.3 ((detached/d6946b4)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400030020

=== Apple Developer Tools ===

Xcode 6.4 (7720)
Build 6E35b

=== Xamarin.iOS ===

Version: 8.10.4.46 (Business Edition)
Hash: 2c66d2f
Branch: master
Build date: 2015-08-04 13:52:25-0400

=== Xamarin.Android ===

Version: 5.1.5.3 (Business Edition)
Android SDK: /Users/nativolabs/Library/Developer/Xamarin/android-sdk-mac_x86
	Supported Android versions:
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Not Installed

=== Build Information ===

Release ID: 509050010
Git revision: 48d16bc4f12ce3938964fc7c3d72fdc6887ad4ad
Build date: 2015-08-18 16:55:24-04
Xamarin addins: c2d51b360ad9f59e689046d47030df27de28f94a

=== Operating System ===

Mac OS X 10.10.5
Darwin Nativos-MBP.home 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
Comment 9 ivanovmeya 2015-10-06 06:32:08 UTC
Hey! We experience this problem on Lenovo and Meizu devices and some others.
Any updates?
Comment 10 marcos.henrich 2015-10-13 09:34:12 UTC
I am not able to reproduce this issue in the devices that are available to me.

Below is a script that should give us the details we need to better understand what is causing this. If you have a device with such problem please let me know the output.

https://gist.github.com/esdrubal/c018dd17cfd354bdf9ef
Comment 12 Rulon 2015-10-16 10:06:04 UTC
Created attachment 13375 [details]
Dump from device failing  With TimeZoneNotFoundException
Comment 13 marcos.henrich 2015-10-28 07:23:07 UTC
Hi Rulon,

Thanks to your input we now know that the problem is not related with a bad timezone id.
It seems to be a problem while parsing the timezone data.

I updated the script to dump the data of problematic timezones. The output from the updated script should be enough to reproduce the parsing errors on my end.

Please let me know the output of the updated script.
https://gist.github.com/esdrubal/c018dd17cfd354bdf9ef
Comment 14 Rulon 2015-10-30 09:40:36 UTC
Created attachment 13583 [details]
output of the updated script

Hi,

I added the output of the updated script.

Thanks.
Comment 15 Christer Nordvik 2015-11-10 04:21:46 UTC
Not sure if it is related but we get the same crash on Xamarin.iOS on jailbroken phones (Cydia) running 8.4. 

Unhandled Exception:
System.TimeZoneNotFoundException: Exception of type 'System.TimeZoneNotFoundException' was thrown.
  at System.TimeZoneInfo.GetMonoTouchData (System.String name, Boolean throw_on_error) [0x00000] in <filename unknown>:0 
  at System.TimeZoneInfo.CreateLocal () [0x00000] in <filename unknown>:0 
  at System.TimeZoneInfo.get_Local () [0x00000] in <filename unknown>:0 
  at System.TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc (DateTime time, System.Boolean& isAmbiguousLocalDst) [0x00000] in <filename unknown>:0 
  at System.DateTime.get_Now () [0x00000] in <filename unknown>:0
Comment 16 marcos.henrich 2015-11-16 11:03:23 UTC
@Rulon Once again thanks for the helpful dump. Thanks to it I was able to reproduce the bug.

Details about problem and fix can be found in PR 2227.
https://github.com/mono/mono/pull/2227

@Christer, @Manuel, I am assuming that the IOS problem is the same as in Android. An unprecedented  timezone data format that made our parser to crash.

Fixed in master 3bc22b19614835c73c42101eaf58de6f666ef81a
https://github.com/mono/mono/commit/3bc22b19614835c73c42101eaf58de6f666ef81a

Fixed in mono-4.3.1-branch  48a394857e49db36fa3eafeb6275327b70ccc691
https://github.com/mono/mono/commit/48a394857e49db36fa3eafeb6275327b70ccc691

Pending approval for mono-4.2.0-branch C6 SR1
https://github.com/mono/mono/pull/2235
Comment 17 anemtsev 2015-11-27 09:16:58 UTC
Waiting for appearing of this fix at Stable branch of Xamarin Studio.
Building Mono from the sources is not so easy solution...
Comment 18 marcos.henrich 2015-12-01 16:01:40 UTC
The fix should be included on the next stable update, service release 1.

Fixed in mono-4.2.0-branch 58731e1bbbfc5c3a7750123e19293e3067a9996d
https://github.com/mono/mono/commit/58731e1bbbfc5c3a7750123e19293e3067a9996d
Comment 20 David Conlisk 2016-08-25 09:26:17 UTC
Hi all,

I've just had Xamarin Insights report this issue on an iPhone 4S running iOS 9.3.4

I don't know what timezone the user is in. 

Insights Output:

System.TimeZoneNotFoundExceptionException of type 'System.TimeZoneNotFoundException' was thrown.
Raw
  at System.TimeZoneInfo.GetMonoTouchData (System.String , Boolean ) <0x2dbd81 + 0x00075> in <filename unknown>:0 
  at System.TimeZoneInfo.CreateLocal () <0x2dbd19 + 0x00018> in <filename unknown>:0 
  at System.TimeZoneInfo.get_Local () <0x2dbe1d + 0x00020> in <filename unknown>:0 
  at System.TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc (DateTime , System.Boolean& ) <0x2dc459 + 0x0001c> in <filename unknown>:0 
  at System.DateTime.get_Now () <0x25c745 + 0x0005a> in <filename unknown>:0 
  at System.Timers.Timer.MyTimerCallback (System.Object ) <0x48107d + 0x00024> in <filename unknown>:0 
  at System.Threading.Timer+Scheduler.TimerCB (System.Object ) <0x3172a9 + 0x0002a> in <filename unknown>:0 
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () <0x2da145 + 0x00030> in <filename unknown>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () <0x3af7c8 + 0x0022b> in <filename unknown>:0 
  at ObjCRuntime.Runtime.ThreadPoolDispatcher (System.Func`1 ) <0x1964dd + 0x00030> in <filename unknown>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () <0x2da029 + 0x00062> in <filename unknown>:0 


Xamarin versions:

=== Xamarin Studio Business ===

Version 6.0.1 (build 9)
Installation UUID: 102f0761-30e9-4572-a57d-f0e70c7d99fc
Runtime:
	Mono 4.4.1 (mono-4.4.0-branch-c7sr0/4747417) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 404010000

=== Xamarin.Profiler ===

Not Installed

=== Apple Developer Tools ===

Xcode 7.3.1 (10188.1)
Build 7D1014

=== Xamarin.iOS ===

Version: 9.8.1.4 (Xamarin Business)
Hash: 3cf8aae
Branch: c7sr0
Build date: 2016-06-20 16:09:58-0400

=== Xamarin.Android ===

Version: 6.1.1.1 (Xamarin Business)
Android SDK: /Users/David/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.4   (API level 19)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 25.1.7
SDK Platform Tools Version: 24.0.1
SDK Build Tools Version: 23.0.3

Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Android Player ===

Not Installed

=== Xamarin.Mac ===

Version: 2.8.1.4 (Xamarin Business)

=== Build Information ===

Release ID: 600010009
Git revision: e879ce52093257c5c386ad7e390dfaa937fa7f90
Build date: 2016-06-24 11:53:43-04
Xamarin addins: a9252e6df4851fbbed1f9c6228e7b6dd1b475ac5
Build lane: monodevelop-lion-cycle7-sr0

=== Operating System ===

Mac OS X 10.11.5
Darwin Davids-MBP 15.5.0 Darwin Kernel Version 15.5.0
    Tue Apr 19 18:36:36 PDT 2016
    root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64

Thanks,

David
Comment 21 Brendan Zagaeski (Xamarin Support) 2016-08-25 15:05:38 UTC
I believe Comment 7, Comment 15, and Comment 20 match Bug 28300 about jailbroken iOS devices.  That bug is currently not resolved.
Comment 22 David Conlisk 2016-08-25 15:43:24 UTC
@Brendan you are right, Insights tells me that this device has been jailbroken.
Comment 23 Riz Mawani 2016-09-17 22:27:46 UTC
For anybody who is still struggling with the TimeZoneNotFoundException, I managed to find a workaround that was originally found by HHumbert on Reddit. 

Use NewTerminal (or any other Terminal emulator) or SSH into the offending device, login as superuser and type in the following, verbatim:

cd /var/db/timezone
mv zoneinfo zoneinfo.broken
ln -s /usr/share/zoneinfo.default zoneinfo

HHumbert explains the issue and circumstances of his find more clearly in his Reddit post, as follows:

https://www.reddit.com/r/jailbreak/comments/3ll1rf/tutorial_solution_how_to_fix_broken_timezone_in/

The above seemed to do the trick for me and I hope it helps others as well!

RM

Note You need to log in before you can comment on or make changes to this bug.