Bug 5619 - App crashes on Camera Intent open from dynamic button
Summary: App crashes on Camera Intent open from dynamic button
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler ()
Version: 4.2.x
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Marek Habersack
: 5572 ()
Depends on:
Reported: 2012-06-12 15:25 UTC by Mike
Modified: 2017-05-13 18:13 UTC (History)
4 users (show)

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

Image button code snippet (3.91 KB, text/plain)
2012-06-12 15:25 UTC, Mike

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 Mike 2012-06-12 15:25:13 UTC
Created attachment 2044 [details]
Image button code snippet

I dynamically create an ImageButton - set it's bitmap if applicable and allow
user to click ImageButton to re-capture image if need be by using the Camera

If I click the ImageButton very first time the Camera Intent launches perfectly
and I can take the picture and OnActivityResult I set the ImageButton URI to
the Image just taken. The ImageButton gets disposed of after I click a "Next"
button which performs some more dynamic screen layout stuff. Later on the
ImageButton gets re-created again in the same Activity/Screen and when I click
it again, the  Camera Intent opens however the application bombs out. No
seemingly useful debug output is presented to help trace where I'm going
wrong... If I am... This was working perfectly prior to the upgrade to
4.2.2 - also broken in 4.2.3

To make matters even more confusing I uninstalled 4.2.2 and reverted to 4.0.1 -
 Same thing occurred -  I then re-installed 4.2.2 again. This just seemed to
make the issue happen more frequently. I've googled all I can, tried only creating the ImageButton once and keeping it in memory I've tried removing the Event Handler after the ImageButton is used just incase it was triggering the event twice. I've tried setting the Activity flag of the Camera Intent to "SingleTop" & "NoHistory" to no avail. I've tried everything I can think of :-)

Tried this on Sony Xperia Arc, Samsung Galaxy Y, Samsung Galaxy Note. All same

Reproducible: Always

Steps to Reproduce:
1. Dynamically create ImageButton.
2. Draw Bitmap to ImageButton from sqlLite if exists
3. Re-take photo using Camera Intent
4. New image to replace old one on ImageButton
5. Click another button which clears the screen and draws something else,
button,radio's etc...
6. Click that other button again to recreate ImageButton use same EventHandler
as before.
7. Draw Bitmap to ImageButton from sqlLite if exists
8. Click the ImageButton
9. Camera Intent opens (sometimes can take image then app crashes - rarely)
10. VS 2012 debugging disconnects and app exists/crashes
Actual Results:  
VS 2012 debugging disconnects and app exists/crashes

Expected Results:  
VS 2012 debugging remains and app doesn't crash.

06-03 15:38:59.174 D/dalvikvm(30484): GC_CONCURRENT freed 27K, 47% free
2854K/5379K, external 2857K/3568K, paused 2ms+4ms
06-03 15:39:03.234 D/OnCreate(30484): here
06-03 15:39:08.164 I/dalvikvm(30484): Total arena pages for JIT: 11
06-03 15:39:23.414 D/dalvikvm(30484): GC_CONCURRENT freed 580K, 49% free
3198K/6215K, external 2889K/3559K, paused 3ms+2ms
06-03 15:39:31.804 D/dalvikvm(30484): GC_CONCURRENT freed 171K, 45% free
3642K/6599K, external 6774K/8459K, paused 7ms+13ms
06-03 15:39:33.854 D/imgPhoto_Click(30484): my URI:
06-03 15:39:33.864 D/imgPhoto_Click(30484): About to launch camera intent
06-03 15:39:33.884 D/imgPhoto_Click(30484): Completed launch of camera intent
06-03 15:39:37.944 W/IInputConnectionWrapper(30484): showStatusIcon on inactive
06-03 15:39:43.684 D/OnActivityResult(30484): my URI:
06-03 15:39:43.854 D/dalvikvm(30484): GC_CONCURRENT freed 404K, 51% free
3286K/6599K, external 14577K/16625K, paused 3ms+14ms
06-03 15:39:54.134 D/dalvikvm(30484): GC_EXPLICIT freed 535K, 55% free
3015K/6599K, external 14577K/16625K, paused 27ms
06-03 15:39:54.134 I/monodroid-gc(30484): GC cleanup summary: 390 objects
tested - resurrecting 88.
06-03 15:40:18.374 D/imgPhoto_Click(30484): my URI:
06-03 15:40:18.374 D/imgPhoto_Click(30484): About to launch camera intent
06-03 15:40:18.404 D/imgPhoto_Click(30484): Completed launch of camera intent
The program 'Mono' has exited with code 255 (0xff).

I really would appreciate any help on resolving this, as it's put a block on all my future upgrades/enhancements.
Comment 1 Mike 2012-06-13 17:11:41 UTC
As an attempt at a workaround I've now tried moving the whole take picture thing to a new activity outside of my whole dynamic screen layout thing... although I still make use of my dynamically generated screen ImageButton to start up the new Activity that I've created.

Unfortunately it didn't work either. It also bombed in the same fashion it did before. I'm convinced something is lingering that is causing the calling app/my app to crash I'm just not sure what it is. 

There are other regions in my app that do not have the Layout generated dynamically and it all works as expected.

Any news from your side on this?

Comment 2 Mike 2012-06-16 02:32:18 UTC
I've been doing some more reading on previous release notes


More event listener methods are bound to events

This may be related?

Is there someone I can bribe to make this issue disappear ?? :))
Comment 3 Mike 2012-06-20 12:37:16 UTC
I've now completely uninstalled 4.2.2/4.2.3 rebooted... and installed 4.0.4

it's working again... something you introduced inbetween then and now has resulted in creating this bug. I reckon it's something to do with your events registration mechanism...
Comment 4 Mike 2012-06-27 10:05:27 UTC
It's back... sigh.. just seems to happen more randomly now... this is really frustrating for me as I cannot rollout any more upgrades for any enhancements i've added to the app...

i need some form of response so i can either abandon further attempts at getting this to work and wait for a bug fix or should just tell my app users that this type of functionality is not supported...

haven't seen any response on this bug report, mostly looks like a monologue of a desperate fool....
Comment 5 Marek Habersack 2016-09-02 20:48:15 UTC
*** Bug 5572 has been marked as a duplicate of this bug. ***
Comment 6 Marek Habersack 2016-09-05 16:56:53 UTC
@Mike, it's been obviously years since you filed this bug, but can you please check whether it still happens with the latest XA releases? If yes, then please attach a full, self-contained, application that reproduces it. You list enough steps to reproduce it that the cause might not be quite that obvious. Thanks!
Comment 7 Mike 2016-09-06 04:44:23 UTC
Hi Marek, thanks for getting back to me - albeit as you say, years later :-). I stopped using Xamarin actually and now just use native code. Seems to have less "gotchas" thanks tho for the efforts. Have a great day. Mike
Comment 8 Marek Habersack 2016-09-06 12:55:05 UTC
Thanks Mike and good luck with your future endeavours!