Bug 52583 - Java.Lang.NullPointerException during Device.StartTimer in XAML Previewer context
Summary: Java.Lang.NullPointerException during Device.StartTimer in XAML Previewer con...
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Chris King
Depends on:
Reported: 2017-02-16 20:51 UTC by Kyle White
Modified: 2017-06-19 21:41 UTC (History)
5 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 52583 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Kyle White 2017-02-16 20:51:45 UTC
*Apologies off the bat if I filed this in the wrong product*

## Simple repo

1) Clone https://github.com/xamarin/xamarin-forms-samples/tree/master/XAMLSamples
2) Build it and open ClockPage.xaml in the *Android* Previewer 

## Result
Preview renders correctly but quickly blows up with "Connection is closed" error. "quickly" is actually 1 second because I believe the culprit of this failure is the use of `Device.StartTimer` in this XAML pages ViewModel: https://github.com/xamarin/xamarin-forms-samples/blob/master/XAMLSamples/XamlSamples/XamlSamples/ClockViewModel.cs#L17-L21

If I comment out this call, things work correctly after rebuilding.

Note: the iOS preview is not affected.

Here is my Ide.log and what I believe to be the relevant trace: https://gist.github.com/kdubau/482280faecba062e4e666c46e7b187d7#file-ide-2017-02-16__12-37-38-log-L604-L618
Comment 1 Paul DiPietro [MSFT] 2017-02-24 20:02:31 UTC
Reassigning to previewer team to take a look at.
Comment 2 Alan McGovern 2017-02-24 20:07:55 UTC
For future reference, the stacktrace involves only Xamarin.Forms and Xamarin.Android. Bugs like that nearly always (99% of the time) fall into the realm of Xamarin.Forms and/or Xamarin.Android.

This particular one looks like a Xamarin.Forms bug, looper is likely to be null here, https://github.com/xamarin/Xamarin.Forms/blob/b6cb64e4930de9b16309f2d30c6bb0a2177048fd/Xamarin.Forms.Platform.Android/Forms.cs#L292

I believe this is the same issue as in upstream android, so you can apply the same fix they did: https://github.com/xamarin/xamarin-android/commit/fbf79bb0b268f81b9754f175ecc1475f87cdae24
Comment 3 Paul DiPietro [MSFT] 2017-02-24 20:30:35 UTC
Thanks Alan. Will do.
Comment 4 Alan McGovern 2017-02-24 20:34:57 UTC

There'll probably be lots of little issues like so spreading the knowledge about how to triage them will help balance the load :)
Comment 5 Alan McGovern 2017-02-24 22:04:43 UTC
Can we get this backported to 2.3.4 as well so we can include it with the final 2.3.4 release?