Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6063] App crashes when defaultImage is not valid

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionNeeds more info
Resolution Date2019-01-17T16:10:36.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterAlberto Marcone
AssigneeShak Hossain
Created2018-12-14T08:26:42.000+0000
Updated2019-01-17T16:10:37.000+0000

Description

UPDATE: The crash happened because the url of the defaultImage was "/". It took us a long time to find it out, a possible enhancement would be to check if the passed url is valid. Thank you ----------- If I pass a simple url string to an ImageView inside a Widget:
$.imageView.setImage("http://path/to/image.png");
I get the crash:
[ERROR]   message = "*** -[__NSCFString substringFromIndex:]: Index 180 out of bounds; string length 179";
[ERROR]   nativeStack = "3 Foundation 0x000000010feeaa3b -[NSString substringFromIndex:] + 126\n4 *** 0x000000010d35f540 -[ImageLoader entryForKey:] + 896\n5 *** 0x000000010d35fec8 -[ImageLoader loadImmediateImage:withSize:] + 72\n6 *** 0x000000010d2d7fab -[TiUIImageView loadDefaultImage:] + 443\n7 *** 0x000000010d2d868c -[TiUIImageView loadUrl:] + 1580\n8 *** 0x000000010d2d9665 -[TiUIImageView setImage_:] + 677\n9 *** 0x000000010d2e84bc DoProxyDelegateReadKeyFromProxy + 268\n10 *** 0x000000010d2e889d DoProxyDelegateReadValuesWithKeysFromProxy + 653\n11 *** 0x000000010d26bcc6 -[TiUIView readProxyValuesWithKeys:] + 54\n12 *** 0x000000010d24102e -[TiViewProxy firePropertyChanges] + 158\n13 *** 0x000000010d23e433 -[TiViewProxy view] + 691\n14 *** 0x000000010d23e5c9 -[TiViewProxy view] + 1097\n15 ASL Biella 0x000000010d23e5c9 -[TiViewProxy view] + 1097\n16 *** 0x000000010d23e5c9 -[TiViewProxy view] + 1097\n17 *** 0x000000010d23e5c9 -[TiViewProxy view] + 1097\n18 *** 0x000000010d23e5c9 -[TiViewProxy view] + 1097\n19 *** 0x000000010d37fc49 -[TiUIScrollableView renderViewForIndex:] + 249";
This doesn't happen when the imageView is outside the widget. Apparently the problem is inside ImageLoader.m, the snippet at line 447
- (ImageCacheEntry *)entryForKey:(NSURL *)url
...
if (result == nil) {
    if ([url isFileURL]) // Load up straight from disk
    {    
      NSString *path = [url path];
....
isFileUrl returns true even if it's a remote url.

Comments

  1. Sharif AbuDarda 2019-01-03

    Hello, Please share a standalone sample project that demonstrates the issue described. Thanks.
  2. Rakhi Mitro 2019-01-17

    Hello, We haven't heard back from you since our last response. I thought I’d check in to see how things are progressing with your need. Let us know if the problem persists and share the sample project.

JSON Source