Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1549] ImageView with remote image in ListView crash: cachePathForURL EXC_BAD_ACCESS KERN_INVALID_ADDRESS

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2015-06-29T16:45:52.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labels3.3.0, 3.4.1, TCSupportTriage, cache, crash, imageview, ios, iphone, listview
ReporterAlex Bernier
AssigneeRadamantis Torres-Lechuga
Created2014-12-30T05:51:49.000+0000
Updated2016-03-08T07:38:00.000+0000

Description

I've never seen this crash myself, but we get ~130-140 crashes a day reported in Crashlytics on this line (ImageLoader.m:294). In the code, I have a ListView with one ListSection, and use the following code to append ListViewItems 10 at a time, as the user scrolls (using a marker). Scrolling is allowed indefinitely. I'm guessing this crash is happening for users who view hundreds or thousands of ListViewItems, because I've never seen it happen in my normal usage of maybe a hundred ListViewItems in a ListView: The ListView template is very basic (image property is set by appendItems):
var SCREEN_WIDTH = Ti.Platform.displayCaps.platformWidth;

var template = {
	properties : {
		backgroundColor : "#fff",
		height : Ti.UI.SIZE
	},
	childTemplates : [{
		type : "Ti.UI.View",
		properties : {
			layout : "vertical",
			width : Ti.UI.FILL,
			height : Ti.UI.SIZE,
			backgroundColor : "#fff"
		},
		childTemplates : [{
			type : "Ti.UI.ImageView",
			bindId : "photo",
			properties : {
				backgroundColor : "#fff",
				height : SCREEN_WIDTH,
				width : SCREEN_WIDTH,
				preventDefaultImage : true
			}
		}]
	}]
};
Using simple appendItems to add 10 items at a time:
//'section' is a reference to the singleListViewSection. 'data' is the image property on the 'photo' bindId above and text for a Label in the template

section.appendItems([data], {
		animated : false,
		animationStyle : Ti.UI.iPhone.RowAnimationStyle.NONE
});
And here's the crash thread dump:
Thread : Crashed: NSOperationQueue 0x158415d0 :: NSOperation 0x14541400
0  libsystem_c.dylib              0x2f9577d4 strlen + 28
1  APPNAME                       0x000edfd9 +[ImageCacheEntry cachePathForURL:] (ImageLoader.m:294)
2  APPNAME                       0x000edfd9 +[ImageCacheEntry cachePathForURL:] (ImageLoader.m:294)
3  APPNAME                       0x000edbb9 -[ImageCacheEntry initWithURL:] (ImageLoader.m:229)
4  APPNAME                       0x000ee6f9 -[ImageLoader setImage:forKey:hires:] (ImageLoader.m:432)
5  APPNAME                       0x000eebe3 -[ImageLoader cache:forURL:size:hires:] (ImageLoader.m:540)
6  APPNAME                       0x000ef8c1 -[ImageLoader request:onLoad:] (ImageLoader.m:789)
7  APPNAME                       0x002e1a79 -[APSHTTPRequest invokeCallbackWithState:] (APSHTTPRequest.m:343)
8  CFNetwork                      0x218015a1 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 56
9  Foundation                     0x2299dae1 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 8
10 Foundation                     0x22908b7d -[NSBlockOperation main] + 148
11 Foundation                     0x228fb337 -[__NSOperationInternal _start:] + 774
12 Foundation                     0x229a044b __NSOQSchedule_f + 186
13 libdispatch.dylib              0x2f922651 _dispatch_queue_drain + 952
14 libdispatch.dylib              0x2f91d09d _dispatch_queue_invoke + 84
15 libdispatch.dylib              0x2f923ba1 _dispatch_root_queue_drain + 320
16 libdispatch.dylib              0x2f924cd7 _dispatch_worker_thread3 + 94
17 libsystem_pthread.dylib        0x2fa7be31 _pthread_wqthread + 668
I'm happy to provide any information I can, or even use a modified SDK and report back results or add more logging. Let me know what I can do.

Attachments

FileDateSize
crashlytics-device-info.png2014-12-30T05:51:49.000+000082370

Comments

  1. Vladimir Tolstikov 2015-05-27

    SDK 3.5.1.GA. See the same EXC_BAD_ACCESS when app trying to load non-existing remote image. Happens randomly. Not tried in 4.0.0 yet. Backtrace from Xcode: #0 0x000000019477bbdc in objc_msgSend () #1 0x000000010017e12c in -[ImageLoaderRequest cancel] at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/ImageLoader.m:334 #2 0x00000001001084a8 in -[TiUIImageViewProxy cancelPendingImageLoads] at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiUIImageViewProxy.m:203 #3 0x000000010010bf4c in -[TiUIImageView cancelPendingImageLoads] at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiUIImageView.m:445 #4 0x000000010010d648 in -[TiUIImageView setImage_:] at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiUIImageView.m:667 #5 0x000000010011aa90 in __DoProxyDelegateChangedValuesWithProxy_block_invoke54 at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiProxy.m:92 #6 0x00000001001513cc in __TiThreadPerformOnMainThread_block_invoke at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiBase.m:270 #7 0x0000000100151810 in TiThreadProcessPendingMainThreadBlocks at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiBase.m:367 #8 0x00000001001515e0 in __TiThreadPerformOnMainThread_block_invoke208 at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiBase.m:308 #9 0x00000001011e4e30 in _dispatch_call_block_and_release () #10 0x00000001011e4df0 in _dispatch_client_callout () #11 0x00000001011e975c in _dispatch_main_queue_callback_4CF () #12 0x0000000184021fa4 in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ () #13 0x000000018402004c in __CFRunLoopRun () #14 0x0000000183f4d0a4 in CFRunLoopRunSpecific () #15 0x000000018d0ef5a4 in GSEventRunModal () #16 0x000000018887eaa4 in UIApplicationMain () #17 0x0000000100069b48 in main at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/main.m:37 #18 0x0000000194dd6a08 in start () Enqueued from com.apple.root.default-qos.overcommit (Thread 8)Queue : com.apple.root.default-qos.overcommit (serial) #0 0x00000001011f2dac in _dispatch_barrier_async_f_slow () #1 0x0000000100150f14 in TiThreadPerformOnMainThread at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiBase.m:311 #2 0x000000010011a958 in DoProxyDelegateChangedValuesWithProxy at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiProxy.m:92 #3 0x00000001000cc30c in -[TiUIView propertyChanged:oldValue:newValue:proxy:] at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiUIView.m:887 #4 0x0000000100120a00 in -[TiProxy replaceValue:forKey:notification:] at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiProxy.m:1154 #5 0x00000001001082f8 in -[TiUIImageViewProxy setImage:] at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/TiUIImageViewProxy.m:184 #6 0x0000000100091f58 in -[KrollObject setValue:forKey:] at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/KrollObject.m:937 #7 0x000000010008e7c0 in KrollSetProperty at /Users/bobr/Documents/My/Work/cleverbug/repos/app/build/iphone/Classes/KrollObject.m:292 Operating System Name = Mac OS X Version = 10.10 Architecture = 64bit # CPUs = 4 Memory = 8589934592 Node.js Node.js Version = 0.12.0 npm Version = 2.5.1 Titanium CLI CLI Version = 4.0.0 Titanium SDK SDK Version = 3.5.1.GA SDK Path = /Users/bobr/Library/Application Support/Titanium/mobilesdk/osx/3.5.1.GA Target Platform = iphone
  2. Radamantis Torres-Lechuga 2015-06-26

    [~athorne], [~bobrosoft] can you please attach a test case and steps to reproduce? we can not replicate this issue
  3. Vladimir Tolstikov 2015-06-27

    Hi there. Sorry, my case happened because I tried to fallback to another image on "error" event (i.e. when remote image not found) and that fallback image not exists too (I not noticed that straight away), so that created infinite loop of "error" event triggering which I think lead to some *race condition* in ImageLoader and to that crash. That's a *minor* issue, happened because of my erroneous implementation of fallback images layout, but if you want to repeat, you need something as
       image.addEventListener('error', function(){
           image.image = 'unexisting_fallback_image.jpg';
       });
       
       image.image = 'unexisting_image.jpg';
       
  4. Alex Bernier 2015-06-27

    We can't reproduce it. What I can say is we don't use a fallback image, however it's possible for our initial image to 404. If I'm able to reproduce it I'll add a test case.

JSON Source