Bug 36681 - [FormsApplicationActivity] NRE When Replacing CurrentPage's Content When Picker is Unfocused
Summary: [FormsApplicationActivity] NRE When Replacing CurrentPage's Content When Pick...
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.0.0
Hardware: PC Mac OS
: Normal major
Target Milestone: ---
Assignee: Samantha Houts [MSFT]
Depends on:
Reported: 2015-12-07 17:17 UTC by Jimmy [MSFT]
Modified: 2017-09-12 11:57 UTC (History)
6 users (show)

Tags: ac android picker FormsApplicationActivity, retest, fr
Is this bug a regression?: Yes
Last known good build:

repro project (60.66 KB, application/zip)
2015-12-07 17:17 UTC, Jimmy [MSFT]

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jimmy [MSFT] 2015-12-07 17:17:39 UTC
Created attachment 14149 [details]
repro project

### Overview
When trying to replace an entire page’s content after making a Picker selection, a NullReferenceException is thrown.

In the attached repro project, the current page’s content is being replaced when Picker.Unfocused is fired. This works on iOS, but an exception is thrown on Android.

### Steps to Reproduce
1. Run attach Android project
2. Select an item from the Picker

### Expected Results
After selecting an item, the tab page’s content will be replaced.

### Actual Results
A NullReferenceException is thrown as the Picker is closed.

### Environment Info
=== Xamarin Studio ===

Version 5.10.1 (build 3)
Installation UUID: 94ce5106-6a72-4691-b34e-cd5857b1db66
	Mono 4.2.1 (explicit/6dd2d0d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 402010102

=== Xamarin.Profiler ===

Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 7.1.1 (9081)
Build 7B1005

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: eb4c1ef
Branch: master
Build date: 2015-12-01 02:12:30-0500

=== Xamarin.Mac ===

Version: (Business Edition)

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/jimmygarrido/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.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 22.0.1

Java SDK: /usr
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.5
Location: /Applications/Xamarin Android Player.app

=== Build Information ===

Release ID: 510010003
Git revision: f2021a209d66d49cbc0649a6d968b29040e57807
Build date: 2015-12-01 10:43:40-05
Xamarin addins: dfd4f5103e8951edbc8ac24480b53b53c55e04ff
Build lane: monodevelop-lion-cycle6-baseline

=== Operating System ===

Mac OS X 10.11.1
Darwin Jimmys-MacBook-Pro.local 15.0.0 Darwin Kernel Version 15.0.0
    Sat Sep 19 15:53:46 PDT 2015
    root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
Comment 1 Jimmy [MSFT] 2015-12-07 17:19:50 UTC
Stack trace: https://gist.github.com/jimmgarrido/7f8f7a7b2590e68772c8
Comment 2 Samantha Houts [MSFT] 2016-03-30 23:15:11 UTC
This has been fixed in a recent version. Thanks!
Comment 4 Jimmy [MSFT] 2017-08-15 00:39:06 UTC
Confirming that this has regressed in recent versions. I've updated the original gist with the new stack trace: https://gist.github.com/jimmgarrido/7f8f7a7b2590e68772c8

This only happens when using FormsApplicationActvity. It works without issue when using FormsAppCompatActivity which is the recommended approach now.

### Version Tests   BAD
2.3.5-pre6  BAD
Comment 6 Jimmy [MSFT] 2017-09-08 17:42:25 UTC
This broke in as a result of the fix for bug 42687. 

Created PR for new fix:  https://github.com/xamarin/Xamarin.Forms/pull/1132
Comment 7 Rui Marinho 2017-09-12 11:57:05 UTC
Should be fixed on 2.4.1-pre1