Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-17187] Android: Application crash randomly after selecting picture from gallery

GitHub Issuen/a
TypeBug
Priorityn/a
StatusReopened
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsandroid, core, crash, exalture
ReporterAriel Sztern
AssigneeUnknown
Created2012-08-19T19:13:50.000+0000
Updated2018-02-28T20:03:35.000+0000

Description

From time to time (when I select a few photos from the picture gallery or just take a photo, the application is crashing. I'm looking for memory leaks but everything seems to be ok. The crash happens even before calling the success event. Here is a sample of the code:
function chooseAPhoto() {
Titanium.Media.openPhotoGallery({

success : function(event) {
if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) { addImage(event.media); }
},
cancel : function() {
},
error : function(error) {
},
allowEditing : false,
mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
});
}

Comments

  1. Ariel Sztern 2012-08-19

    I've tried the photo gallery example several times using the KitchenSink and it's happening the same. This is a random problem, you could select 20 images without a problem and just 3 to get the crash. Regards, Ariel
  2. Ariel Sztern 2012-08-28

    Hi, I'm trying to deploy this by today. Is there any progress in fixing this bug? Regards, Ariel
  3. Ariel Sztern 2012-09-02

    Is there any news regarding this issue? I wasn't able to deploy my app last week because of this bug. I really appreciate and support and feedback. Regards, Ariel
  4. Davide Cassenti 2012-09-11

    Hello, I am unable to reproduce the issue (tested your code). I tried on the emulator with Android 2.3.3 and SDK 2.1.2 GA and it never crashed. Are you trying the Emulator or a real device? Which versions of the OS did you try, only 2.2? Thanks
  5. Ariel Sztern 2012-09-11

    I've tried this with 3 phones: a Samsung Galaxy S with Android 2.3.3 an HTC with 2.2, a Samsung Galaxy S3 with 4.0.3 This error also happens with the KitchenSink sample on the device (everything happens on the device). The thing about this, is that you could select 20 pictures without any problem, and the 21 get crashed, or juist 3 pictures and the 4th you get crashed. This is something random, Thanks, Ariel
  6. Ariel Sztern 2012-10-13

    Please, check this issue. Is still happening. Thanks
  7. Davide Cassenti 2013-01-28

    Hello, We've still been unable to replicate the problem; did you still have issues using the latest SDK released?
  8. Adriano Massi 2014-04-16

    Same for me: Nothing inside the "success:" handler seems to be executed when it randomly crashes. (I also totally emptied the "success" handler from any instruction). Monitor log: 04-17 00:28:07.963: V/StateManager(7312): startStateForResult class com.android.gallery3d.app.AlbumPage, 1 04-17 00:28:07.983: D/ImmediateSync(7312): cancel sync all 04-17 00:28:08.023: W/GLSUser(14221): GoogleAccountDataService.getToken() 04-17 00:28:08.053: D/ImmediateSync(7312): sync album for **********************/5033619820827575297 04-17 00:28:08.053: I/GLRootView(7312): layout content pane 1080x1701 (compensation 0) 04-17 00:28:08.313: I/art(760): Heap trim of managed (duration=28.391614ms, advised=8MB) and native (duration=4.473438ms, advised=2MB) heaps. Managed heap utilization of 51%. 04-17 00:28:08.973: D/PicasaAlbumSet(7312): sync result: -1811593058.5033619820827575297: 0 04-17 00:28:08.973: D/AlbumPage(7312): onSyncDone: ******************** result=0 04-17 00:28:09.193: D/ImmediateSync(7312): cancel sync -1811593058.5033619820827575297 04-17 00:28:09.213: E/TiMedia(9769): (main) [6183,102968] OnResult called: -1 04-17 00:28:09.213: W/GalleryProvider(7312): unsupported column: _data 04-17 00:28:09.223: I/EsApplication(10324): Trimming memory (onTrimMemory 60) 04-17 00:28:09.233: I/EsApplication(10324): Trimming memory (onTrimMemory 60) 04-17 00:28:09.243: W/ManagedEGLContext(28714): doTerminate failed: EGL count is 2 but managed count is 1 04-17 00:28:09.253: I/EsApplication(10324): Trimming memory (onTrimMemory 60) 04-17 00:28:10.433: D/MobileDataStateTracker(760): default: setPolicyDataEnable(enabled=true) 04-17 00:28:10.493: I/EsApplication(10324): Trimming memory (onTrimMemory 60) 04-17 00:28:10.513: I/art(10324): Heap trim of managed (duration=2.109480ms, advised=252KB) and native (duration=1.356823ms, advised=136KB) heaps. Managed heap utilization of 64%. 04-17 00:28:19.173: W/ActivityManager(760): Launch timeout has expired, giving up wake lock! I confirm it happens totally random: even selecting the same image that worked in a previous attempt. The devices goes black screen and become unresponsive Device (not emulator): LG Google Nexus 5 Hope it will be fixed cause I can't release my project cause of this Best Adriano
  9. Ryan Buening 2014-06-13

    I also have this issue in my Alloy app. I'm running Titanium 3.2.3. I get this issue every time on my Nexus 4 device. The app doesn't crash every time, but it will occasionally hang and go black. It will then recover after a few seconds. {noformat} [ERROR] : TiMedia: (main) [9798,265278] OnResult called: -1 [INFO] : 10:18:03: success ran [INFO] : I/dalvikvm-heap: Grow heap (frag case) to 46.837MB for 31961104-byte allocation [INFO] : Choreographer: Skipped 93 frames! The application may be doing too much work on its main thread. {noformat}
       function selectPhoto(){
       	Titanium.Media.openPhotoGallery({
       		success : function(event) {
       			DTG.log("success ran");
       			if (event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO) {
       				var submitPhotoWindow = Alloy.createController('submitPhoto', {
       					image : event.media
       				}).getView();
       				
       				submitPhotoWindow.open();
       			}
       		}
       	});
       }
       
  10. Ryan Buening 2014-06-18

    Is there something I should be doing differently in my code above to prevent this issue? Let me know if I need to provide more details on my environment.
  11. Eric Wieber 2014-06-19

    I have been able to reproduce this on a Nexus 4 running 4.2. Titanium SDK 3.2.3.GA CLI 3.2.3 Marking this issue as a bug for further investigation. Thank you for sticking with this issue. We will update you about it as soon as possible.
  12. Adriano Massi 2014-06-20

    Thank you!!!
  13. Nayram 2014-06-24

    Hi I am also facing the same issue when I run my app on a NEXUS 4, android version 4.4.3. Titanium sdk version 3.2.1 GA. I will appreciate some help on this issue.
  14. Giorgio Pagnoni 2014-07-08

    It must be a Nexus thing, since it crashes on my Nexus 7 too because of that "OnResult called: -1". Hope it will be fixed asap, or if you have a workaround please share it with us, thank you!
  15. Sunila 2014-09-24

    The out of memory crashes can be avoided by scaling down the images before it is set to the imageview. Some of these devices may have high resolution camera and the image size may be too big to load in the memory. To resize the image, do something like anImageView.image = e.media.imageAsResized(600,600);
  16. Dharmik Patel 2014-10-17

    Hi I am also facing the same issue in Ti. SDK : 3.4.0 :(

JSON Source