Bug 38230 - Using Facebook LoginButton and Debugging => crash
Summary: Using Facebook LoginButton and Debugging => crash
Status: NEEDINFO
Alias: None
Product: Components
Classification: Xamarin
Component: Xamarin Components ()
Version: N/A
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Peter Collins
URL:
Depends on:
Blocks:
 
Reported: 2016-01-31 14:21 UTC by Ken Domino
Modified: 2016-04-28 14:48 UTC (History)
4 users (show)

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


Attachments
FB crash in debugger program (4.69 MB, application/x-zip-compressed)
2016-01-31 14:21 UTC, Ken Domino
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 for Bug 38230 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:
Status:
NEEDINFO

Description Ken Domino 2016-01-31 14:21:03 UTC
Created attachment 14820 [details]
FB crash in debugger program

Attached is a very simple app that using Facebook login button. The good news is that when it is executed in a debugger without any breakpoints, or not in a debugger, it works. The problem is when you try to run it in a debugger. After invoking the FB login by clicking on the button, *any* breakpoint anywhere (if hit) will cause an exception which is unrecoverable.

To reproduce, unpack the project, build, set a breakpoint at the line "base.OnRestart();" in MainActivity.cs, then debug (Xamarin Studio or Visual Studio). While debugging, click on the FB button. It now displays a blank activity. (The FB facebook_app_id is set to a number which is not registered app id number, but even set to a registered FB app ID, it crashes.) Click on the "X" to close the FB login box. The debugger stops at the breakpoint, but it displays an unrecoverable exception:

System.NullReferenceException: Object reference not set to an instance of an object
  at App3.MainActivity.OnRestart () [0x00001] in C:\Users\Ken\documents\visual studio 2015\Projects\App3\App3\MainActivity.cs:20
  at Android.App.Activity.n_OnRestart (IntPtr jnienv, IntPtr native__this) [0x00009] in /Users/builder/data/lanes/2692/e98e9627/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:4539
  at at (wrapper dynamic-method) System.Object:bac4a831-2911-4df5-96bb-0e1509263fdb (intptr,intptr)

Once the exception occurs, you can't continue--the app stops. As long as I don't use the FB login, I can debug, but that sort of make it difficult to develop a program.

This uses the "Facebook SDK for Xamarin Android" 4.9.0.0, but it's failed for many prior versions.


======

=== Xamarin Studio ===

Version 5.10.2 (build 56)
Installation UUID: 6b561932-1b36-4c68-b3e6-279a395f4109
Runtime:
	Microsoft .NET 4.0.30319.42000
	GTK+ 2.24.23 (MS-Windows theme)
	GTK# 2.12.30

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 6.0.1.10 (Business Edition)
Android SDK: C:\Users\Ken\AppData\Local\Android\android-sdk
	Supported Android versions:
		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.1

SDK Build Tools Version: 23.0.2


Java SDK: C:\Program Files\Java\jdk1.8.0_60
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

=== Xamarin Android Player ===

Version: 0.6.5
Location: C:\Program Files\Xamarin Android Player\DeviceManager.exe

=== Build Information ===

Release ID: 510020056
Git revision: bb74ff467c62ded42b7b7ac7fdd2edc60f8647b0
Build date: 2016-01-26 15:49:39-05
Xamarin addins: 8b797d7ba24d5abab226c2cf9fda77f666263f1b
Build lane: monodevelop-windows-cycle6-c6sr1

=== Operating System ===

Windows 10.0.10586.0 (64-bit)
Comment 1 Ken Domino 2016-01-31 14:34:29 UTC
Note--the equivalent minimal app developed with Java/Android Studio works perfectly fine--no crashes.
Comment 2 Ken Domino 2016-01-31 18:10:17 UTC
I have a workaround, but it is not pleasant to contemplate. In my example, the trick is to place a breakpoint in a try/catch block that catches the exception, e.g.,

try
{
 GC.Collect(); // place breakpoint here.
}
catch (Exception e)
{}

Start debugging. Then, cancel the FB login screen. Try FB login a second time. This time, the exception is never generated again, and all code works perfectly fine!
Comment 4 Ken Domino 2016-02-02 23:35:28 UTC
Hi Bill & Peter,

I've new information. This bug appears only with the Xamarin Android Player--and the version I use is still just prerelease (just downloaded it this afternoon). When debugged on a physical Android phone, the app debugs fine--no exceptions thrown at a breakpoint after the FB dialog box. However, on another fresh, clean Windows 10 machine with the latest Xamarin products--using the Player--the bug is reproducible. Sorry--I've been working mostly with the Xamarin Android Player because it works so well. Hope this helps iron out some problems in the Player. I look forward to its release.

-Ken
Comment 5 Abhishek 2016-02-04 15:03:12 UTC
I have tried this issue but unable to reproduce this issue at my end.

I have followed the description given above but I am unable to get the exception at my end. I have checked this issue with the latest Preview release XAP 0.6.5 on Windows and Mac as well. But I am unable to see the exception after breakpoint hit on clicking "X" button. Even Also after setting the Facebook App ID I am unable to reproduce at my end. Could you please let me know how can I reproduce this issue at end? Also it would be great if you provide the IDE log and adb logcat.

IDE log via Help->Open Log Directory.

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

Environment Info:

=== Xamarin Studio ===

Version 5.10.2 (build 56)
Installation UUID: 44f32fb4-6305-4e48-b118-0df2876ead69
Runtime:
 Microsoft .NET 4.0.30319.42000
 GTK+ 2.24.23 (MS-Windows theme)
 GTK# 2.12.30

=== Xamarin.Profiler ===

Not Installed

=== Xamarin.Android ===

Version: 6.0.1.10 (Enterprise Edition)
Android SDK: D:\android-sdk
 Supported Android versions:
  2.3    (API level 10)
  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)
  5.1    (API level 22)
  6.0    (API level 23)

SDK Tools Version: 24.4.1

SDK Platform Tools Version: 23.1

SDK Build Tools Version: 23.0.2


Java SDK: C:\Program Files\Java\jdk1.7.0_71
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)

=== Xamarin Android Player ===

Version: 0.6.5
Location: C:\Program Files\Xamarin Android Player\DeviceManager.exe

=== Build Information ===

Release ID: 510020056
Git revision: bb74ff467c62ded42b7b7ac7fdd2edc60f8647b0
Build date: 2016-01-26 15:49:39-05
Xamarin addins: 8b797d7ba24d5abab226c2cf9fda77f666263f1b
Build lane: monodevelop-windows-cycle6-c6sr1

=== Operating System ===

Windows 10.0.10240.0 (64-bit)
Comment 6 Adam Hunter 2016-04-27 15:36:10 UTC
Same problem here.  We are using 

            FacebookSdk.SdkInitialize(this.ApplicationContext);
            AppEventsLogger.ActivateApp(this);

in OnCreate() of main activity.

I noticed that app just quits on launch if API >= 5

Another work-around is to add  android:debuggable="true" in the <application> element

facebook sdk version 4.10
Comment 7 Adam Hunter 2016-04-28 14:48:18 UTC
#> adb shell setprop debug.mono.env MONO_DEBUG=soft-breakpoints
fixes the problem (on per device basis)