Bug 24777 - jobject must not be IntPtr.Zero exception when replacing Content of a Page
Summary: jobject must not be IntPtr.Zero exception when replacing Content of a Page
Status: VERIFIED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 1.2.3
Hardware: PC Mac OS
: Normal normal
Target Milestone: 1.3.3
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-11-24 13:02 UTC by John Miller [MSFT]
Modified: 2015-02-03 12:52 UTC (History)
6 users (show)

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


Attachments
Test Case (261.02 KB, application/zip)
2014-11-24 13:02 UTC, John Miller [MSFT]
Details


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:
Status:
VERIFIED FIXED

Description John Miller [MSFT] 2014-11-24 13:02:20 UTC
Created attachment 8848 [details]
Test Case

**Overview:**

   An exception is thrown when replacing the content of a page a few times, repeatedly. 

**Steps to Reproduce:**

   1. Run the attach project on an Android API 19 emulator. 
   2. Press the button 10-15 times quickly (~half a second)

**Actual Results:**

   An exception is thrown: 'jobject' must not be IntPtr.Zero

**Expected Results:**

   No exception

**Build Date & Platform:**

   XF 1.2.3

**Additional Information:**

   I noticed that this only happens while the ViewModels timer is firing. If the progress bar finishes before performing step 2, the crash does not happen. It might be related to the Device.StartTimer.
Comment 1 Reza 2014-11-24 13:14:06 UTC
Thanks for raising this.  

I don't *think* it is related to the timer, except that the timer will try to update the property which has a binding set.  Removing it will certainly stop the issue occurring since there is nothing updating the data.  

You could try it with a button which updates the property value instead (I have seen this happen too), but this will make it much harder to reproduce the issue.
Comment 2 Rajneesh Kumar 2014-11-25 02:00:29 UTC
I have checked this issue and able to reproduce this issue. To reproduce this issue I have followed the steps and instruction provided in bug description.

Steps I followed:

1. Open attached test case in XS.
2. Build and deploy the application on API 19 emulator.
3. It deploy successfully, and shows a button "Tap lots of time to reproduce".
4. Press the button 10-15 times quickly.
5. Observe that you will get the following:
"System.ArgumentException: 'jobject' must not be IntPtr.Zero."

Exception: https://gist.github.com/Rajneesh360Logica/83956fd86dcf390bd058

Screencast: http://www.screencast.com/t/xtzyYQB24s

App O/P: https://gist.github.com/Rajneesh360Logica/3851b97236c450cd6f3d
Build O/P: https://gist.github.com/Rajneesh360Logica/e96b4f54da24c472ffc5
XS Logs: http://www.screencast.com/t/j6PEtDb8BhC

Environment Info:

=== Xamarin Studio ===

Version 5.5.4 (build 15)
Installation UUID: 1a096c6f-0678-402e-89b2-a2c10f7e80e4
Runtime:
	Mono 3.10.0 ((detached/92c4884)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000031

=== Xamarin.Android ===

Version: 4.20.0.28 (Business Edition)
Android SDK: /Users/360_macmini/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		3.2    (API level 13)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.iOS ===

Version: 8.4.0.43 (Business Edition)
Hash: 840a925
Branch: 
Build date: 2014-11-16 21:03:22-0500

=== Xamarin.Mac ===

Version: 1.10.0.18 (Business Edition)

=== Build Information ===

Release ID: 505040015
Git revision: f93940a35458a18052f1a25e106e62ca970d9c40
Build date: 2014-11-19 15:32:41-05
Xamarin addins: dc23cbd91a3a0e1d326328e1229e86c942a49ec8

=== Operating System ===

Mac OS X 10.9.4
Darwin ShrutiMac.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 3 Reza 2014-11-27 11:17:17 UTC
Anything more I can help with?  Are there any workarounds - The only workaround that I could find is to go through and explicitly remove all bindings.  

Would I be able to go through entire tree starting with the content view and remove each binding - without having to keep a record of what bindings I have added?  I cant seem to find a list of some sort for existing bindings on an object.

Thanks!
Comment 4 Reza 2015-01-12 15:57:47 UTC
Any plans to fix this?
Comment 5 Jason Smith [MSFT] 2015-01-21 03:21:15 UTC
This bug is in progress. We are working out what is causing these objects to be finalized without being disposed still.
Comment 6 Jason Smith [MSFT] 2015-01-28 13:12:09 UTC
Should be fixed in 1.3.3-pre1
Comment 7 Rajneesh Kumar 2015-02-03 09:48:24 UTC
I have checked this issue with the following builds: 

Xamarin.Forms Version: 1.3.3.6318-pre1
Xamarin Studio Version 5.7.1 (build 16)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
Mono 3.12.0 ((detached/a813491)
GTK+ 2.24.23 (Raleigh theme)
Package version: 312000068
Xamarin.Android Version: 4.20.0.28 (Business Edition)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
=== Build Information ===
Release ID: 507010016
Git revision: f12fcaf4707ab436bee2df6263eb5333197b262c
Build date: 2015-02-01 21:06:05-05
Xamarin addins: f7b7d34419c9ec24501bfa7c658e80a6305613e0
Operating System Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
Sun Aug 17 19:50:11 PDT 2014
root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64

I observed that after deploying the application and pressing the button 10-15 times quickly before finishing progress bar, not getting any type of exception. This issue is working fine, here is the screencast for the same: http://www.screencast.com/t/hEiv5q1KeEGO

This issue has been fixed hence closing this issue.