Bug 19034 - 'MediaNotes' sample throws System.NullReferenceExcepton' exception
Summary: 'MediaNotes' sample throws System.NullReferenceExcepton' exception
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: iOS
Classification: Xamarin
Component: Samples ()
Version: 7.2.1
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Rustam Zaitov
URL:
Depends on:
Blocks:
 
Reported: 2014-04-14 11:24 UTC by Shruti
Modified: 2015-08-12 17:05 UTC (History)
5 users (show)

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


Attachments
MediaNotes (1.52 MB, application/zip)
2014-04-16 11:10 UTC, Saurabh
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:
RESOLVED NOT_REPRODUCIBLE

Description Shruti 2014-04-14 11:24:49 UTC
Prerequisite :
1. Create 'WWDC2000' album folder on iPad.
2. Add photos to album.
Step to reproduce:
1. Open MediaNotes sample in XS.
2. Run or Debug the app.

Actual Result :
Application get launched on device and throw exception 'System.NullReferenceExcepton'.

Expected Result : Application should launch successfully on device without any exception.

Screencast Info : http://screencast.com/t/D6b4dVoFvZ 
iOS Device Log : https://gist.github.com/Sadik1/f33522ffc8e2bf37675b
Device Info :  iPad 7.1
App Info : monotouch-samples8f66c27aa2f95a7e56e343990df1de6c26543c22/MediaNotes

Environment Details:
All MAC
XS 4.2.4(build 34)
X.iOS 7.2.1.40


Regression Status:
Same issue also exist with Stable XS 4.2.3(Build 60) and X.iOS 7.2.0.2. But I am not sure is it regression or not with previous builds.
Comment 1 Sebastien Pouliot 2014-04-14 11:36:37 UTC
The "iOS Device Log" does not contain any data related to the app. There's also no point to include this without a (symbolicated) crash report.

In any case *always* include (copy/paste) any exception *and* stack trace into bug reports. I.e. `NullReferenceException` means nothing if we do not know it's coming from the sample or the product code.
Comment 4 Saurabh 2014-04-14 12:33:20 UTC
I have checked this issue with following builds:

=== Xamarin Studio ===

Version 4.2.4 (build 32)
Installation UUID: b1fc3b76-cf00-405e-a0a1-3839ac11fe6d
Runtime:
	Mono 3.2.6 ((no/9b58377)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 302060000

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.iOS ===

Version: 7.2.1.20 (Trial Edition)
Hash: 7342842
Branch: 
Build date: 2014-03-18 18:20:49-0400

=== Build Information ===

Release ID: 402040032
Git revision: a160c35dac9ab9fd32eeadaa171216316d5a5133
Build date: 2014-03-12 13:55:08-04
Xamarin addins: a779416ceabd54981ce812771a4061c942e8b872

=== Operating System ===

Mac OS X 10.9.3
Darwin Apples-iMac.local 13.2.0 Darwin Kernel Version 13.2.0
    Thu Apr  3 21:38:48 PDT 2014
    root:xnu-2422.100.12~2/RELEASE_X86_64 x86_64

This sample is working fine with following devices:

iPad 2 iOS 7.1 => Working fine
iPad 6 iOS 6.1.3 => Working fine

However, we are still getting same issue with iPad mini iOS 7.1

iPasd mini iOS 7.1 => Not working fine and throws exception.

Re-Symbolicate log: https://gist.github.com/AkhileshKumar01/cc75d2d53a2156098aec
Exception details: https://gist.github.com/AkhileshKumar01/84b2006eeb9073b68e12

App info:
monotouch-samples-8f66c27aa2f95a7e56e343990df1de6c26543c22
Comment 5 Sebastien Pouliot 2014-04-14 13:38:36 UTC
Exception Codes: 0x000000008badf00d

^ ate-bad-food -> that's the iOS watchdog killing the process.

The stacktrace also points to the debugger being stopped on Main [1]. It's totally normal for iOS to kill an application (on device) if it does not complete the `FinishedLaunching` under 17 seconds.

That will happen if you set a breakpoint inside code called from FinishedLaunching - which is what's happening here.

It also means the exception is unrelated to the crash report. Please reproduce this without using the debugger.

[1] https://gist.github.com/AkhileshKumar01/cc75d2d53a2156098aec#file-gistfile1-txt-L38
Comment 6 GouriKumari 2014-04-14 14:17:11 UTC
I could reproduce this issue with iPadMini 7.1.  The issue here is : 
CGImage imageRef = rep.GetFullScreenImage () inside , setCurrentPhotoToIndex (int index) is causing the NRE.
Screencast: http://screencast.com/t/wQz3i60GFk

Device Log: https://gist.github.com/GouriKumari/bc566d83956de21dc057

This issue is happening only with iPadMini7.1 and the original iOS sample app works with iPadMini7.1.

Also, the sample app works with iPad2 7.1. I am not able to figure out why it is failing for iPadMini 7.1. 

Test Env:
Xamarin Studio
Version 4.2.3 (build 60)
Installation UUID: 5ed3a124-4b77-4c6f-beb9-c830fd815e2a
Runtime:
	Mono 3.4.0 ((no/9761a75)
	GTK+ 2.24.23 theme: Raleigh
	GTK# (2.12.0.0)
	Package version: 304000195

Apple Developer Tools
Xcode 5.1.1 (5085)
Build 5B1008

Xamarin.iOS
Version: 7.2.2.115 (Enterprise Edition)
Hash: 319a6d5
Branch: 
Build date: 2014-04-11 16:50:46-0400
Comment 7 Sebastien Pouliot 2014-04-14 14:28:16 UTC
@Gouri can you check the app permissions ? (in settings)

Maybe an older version of the sample set the correct permission on the (I assume old) iPad2 ?
Comment 8 Sebastien Pouliot 2014-04-14 14:39:21 UTC
Did you add any pictures in that album ?

Also when you hit your breakpoing on line #109, i.e. 

   CGImage imageRef = rep.GetFullScreenImage ();

is `rep` null ?

From the previous line it could be `null` is the image is noa a JPEG image (maybe a video ?).
Comment 9 GouriKumari 2014-04-14 14:56:42 UTC
is `rep` null ?

From the previous line it could be `null` is the image is not a JPEG image
(maybe a video ?).

The image that I added to the album was .png which was not recognized  and  'rep' was returning a null.
http://screencast.com/t/kdJtfvRX

On adding .jpeg images to album, the app successfully launched on iPadMini7.1, 

http://screencast.com/t/1RgBWzT0y
Comment 10 Sebastien Pouliot 2014-04-14 15:28:12 UTC
Ok, then it's a sample bug, missing null check (when an image cannot be represented as a a jpeg). I'll fix it.
Comment 11 Sebastien Pouliot 2014-04-14 15:40:45 UTC
Fixed in master e607885cdff9548721ea7b08ff07c1aca81eb2bf
Comment 12 Saurabh 2014-04-16 10:12:19 UTC
I have checked this issue with latest iOS sample and I am still getting same issue. As soon as application launches, it throws exception.

iOS Device log: https://gist.github.com/AkhileshKumar01/77890b2ed4fc4a07ef11

Device info: iPad 2 iOS 7.1

monotouch-samples-b24aead7c5b1502b51e412b14448ac3c14b89087

=== Xamarin Studio ===

Version 4.2.4 (build 34)
Installation UUID: b1fc3b76-cf00-405e-a0a1-3839ac11fe6d
Runtime:
	Mono 3.2.6 ((no/9b58377)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 302060000

=== Apple Developer Tools ===

Xcode 5.1.1 (5085)
Build 5B1008

=== Xamarin.iOS ===

Version: 7.2.1.40 (Enterprise Edition)
Hash: 86b1dbd
Branch: 
Build date: 2014-04-11 23:42:07-0400

=== Build Information ===
Release ID: 402040034
Git revision: 4c1b13f2e7dd432e00bb501375d67a0ffb0482db
Build date: 2014-04-09 00:03:20-04
Xamarin addins: 53bde0041263928e8bd64686f5ca5a8e4338dd76
Comment 13 Sebastien Pouliot 2014-04-16 10:22:49 UTC
I'm stopping to ask for stacktraces, logs and crash reports. I'll simply re-assign bugs to PJ
Comment 14 Saurabh 2014-04-16 11:04:32 UTC
Sorry Sebastien, I had not included Re-Symbolicate log because at that time iPad 2 iOS 7.1 device was not connecting with Xcode, I have tried it many times.
In future we would be updating bug with such info as well.

Now, I have checked with device iPad 4 iOS 6.1.3 and observing same issue. This time I have 

Re-Symbolicate log:
https://gist.github.com/AkhileshKumar01/c2a6a288bd27f671c8e7

Device info: iPad 4 iOS 6.1.3

Also as per  Bug 8093, Comment2, for 'MediaNotes' app, 'WWDC2012' album is prerequisite. 
But I have observed one more thing that app crashes only when 'WWDC2012' album is present on the device. And if we delete this album then app deploys successfully on the device and it does not crash. This happens for both devices:

iPad 4 iOS 6.1.3
iPad 2 iOS 7.1
Comment 15 Saurabh 2014-04-16 11:10:56 UTC
Created attachment 6591 [details]
MediaNotes
Comment 16 Sebastien Pouliot 2014-04-16 11:27:22 UTC
It's not just the crash report.

1. You always need to include all version numbers (and you did include it, thanks);

2. If there's an exception (and there's one here) you need to include the exception and stack trace (that should be in the Application Output pad). That gives us the type (of the exception) and where it occurs. 

In this case it cannot be the same (at least not the same location) since the sample code changed. IOW the same exception, but from a different location, could be something else entirely.

3. If there's a crash (and there's one here) then you need to include the symbolicated crash report;

4. Also if there's a crash the device log needs to be attached (and you did, thanks). 

That useful only in some cases (something there's nothing more but in a few cases there are hints that we cannot get from the crash report itself);


However there's no need to attach the (public) sample to the bug report. That can be confusing to verify the bug, e.g. if the fix is in the sample code then your attachment won't have it (it will only be in git).


Now in this specific case you'll need to tell us what was added into the WWDC2012 album.

 I know it works with JPEG and the last (sample) fix should have fixed issue when a PNG image was used. Videos should not be seen (and should not be an issue).
Comment 17 PJ 2014-07-08 17:04:31 UTC
This bug is awaiting info from comment 16:

> Now in this specific case you'll need to tell us what was added into the WWDC2012 album.

Setting to NEEDINFO.
Comment 18 Shruti 2014-07-15 08:30:58 UTC
I have checked it with JPG and PNG images and observed different behavior on different devices.

i) Device info:  iPad 4 iOS 6.1.3
It works for JPG but experiencing same issue with PNG image.

ii) Device info:  iPad 2 iOS 7.1.1
Not working with JPG and PNG image as well.

monotouch-samples41c0bae1e973a23349c9efa318f7ae92cf745e49

Please let me know If I need to add any other information.
Comment 19 Aaron Sky 2015-01-22 14:49:59 UTC
I was unable to reproduce this bug on the latest version of XI (8.6.0) on iPad Air 7.1. I created an album named WWDC2012 containing both a jpg and a png image prior to installing the app, and had no issues on or after launch.

Environment Info:
Xamarin Studio
Version 5.7 (build 661)
Installation UUID: 0c38ad8a-9e2b-4b47-bc12-c639499efc27
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)
Android SDK: /Users/aaronsky/Library/Developer/Xamarin/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)
		4.0.3 (API level 15)
		4.4   (API level 19)
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)

Apple Developer Tools
Xcode 6.1.1 (6611)
Build 6A2008a

Xamarin.iOS
Version: 8.6.0.51 (Business Edition)
Hash: dfb682f
Branch: 
Build date: 2015-01-08 13:39:32-0500

Xamarin.Mac
Version: 1.10.0.18 (Business Edition)

Build Information
Release ID: 507000661
Git revision: b70bab61da996da29045ea8ee8aed1a6faedbe78
Build date: 2015-01-05 16:31:31-05
Xamarin addins: 82f6c71490562d6cd125a09287f441902fdac3d7

Operating System
Mac OS X 10.10.1
Darwin Aarons-iMac.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64