Select to view content in your preferred language

Custom Tiled Layer Sample has NSGenericException

3190
8
09-05-2011 07:27 PM
DaolinShen
New Contributor
2011-09-06 10:45:32.344 zjjt[1627:5f03] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <CALayerArray: 0xb226f50> was mutated while being enumerated.(
    "<CALayer: 0x6036f40>",
    "<CALayer: 0x603ab80>",
    "<CALayer: 0x60179d0>",
    "<CALayer: 0x602e030>",
    "<CALayer: 0x601a3a0>",
    "<CALayer: 0x6033f60>",
    "<CALayer: 0x603b660>",
    "<CALayer: 0xb22a550>",
    "<CALayer: 0x6017b50>",
    "<CALayer: 0x6228670>",
    "<CALayer: 0xb222340>",
    "<CALayer: 0x6039a20>",
    "<CALayer: 0x6040900>",
    "<CALayer: 0xb2223e0>",
    "<CALayer: 0x603cc00>",
    "<CALayer: 0x6036cf0>",
    "<CALayer: 0x6039540>",
    "<CALayer: 0x603b260>",
    "<CALayer: 0x6038b50>",
    "<CALayer: 0x6040430>"
)'
*** Call stack at first throw:
(
0   CoreFoundation                      0x01b7a5a9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x01cce313 objc_exception_throw + 44
2   CoreFoundation                      0x01b7a069 __NSFastEnumerationMutationHandler + 377
3   UIKit                               0x00bfc75c -[UIView(Hierarchy) subviews] + 331
4   zjjt                                0x0007a0ef -[AGSTiledLayerView mapZoomed:] + 546
5   zjjt                                0x00079ec6 -[AGSTiledLayerView mapIsZooming:] + 116
6   zjjt                                0x0006f67e -[AGSMapView kickOffMapIsZooming:] + 321
7   Foundation                          0x0094294e __NSThreadPerformPerform + 251
8   CoreFoundation                      0x01b5b8ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
9   CoreFoundation                      0x01ab988b __CFRunLoopDoSources0 + 571
10  CoreFoundation                      0x01ab8d86 __CFRunLoopRun + 470
11  CoreFoundation                      0x01ab8840 CFRunLoopRunSpecific + 208
12  CoreFoundation                      0x01ab8761 CFRunLoopRunInMode + 97
13  Foundation                          0x00964115 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 295
14  zjjt                                0x000625c0 -[WorkerThreadUnit workerThreadMainRoutine] + 166
15  Foundation                          0x0092dcf4 -[NSThread main] + 81
16  Foundation                          0x0092dc80 __NSThread__main__ + 1387
17  libSystem.B.dylib                   0x98261819 _pthread_start + 345
18  libSystem.B.dylib                   0x9826169e thread_start + 34
)



how??
0 Kudos
8 Replies
DaolinShen
New Contributor
An additional remark�?

My app�?Custom Tiled Layer Sample�? can run�?my custom tiled layer can appear�?but when I zoom in and zoom out frequently�? This error occured ,and the app end unexpected,turned to the ipad's desktop.why this bug happen�?please help me.thanks.
0 Kudos
PaulLohr
Regular Contributor
I've found that setting a breakpoint then stepping through the code will sometimes show where the problem is occurring. You may need to move the breakpoint in a trial and error process to find the problem. Maybe you've tried this already? Sorry I don't have more help on this.
0 Kudos
RickJones
Occasional Contributor II
The tile map class fires off a bunch of operations to load the images in background threads.

It's possible the rapid zoom in/out is overloading the operation threads.
0 Kudos
DaolinShen
New Contributor
The tile map class fires off a bunch of operations to load the images in background threads.

It's possible the rapid zoom in/out is overloading the operation threads.


thanks rick.jones@moncton.org

yes , it's always happen in rapid zoom in/out .

is there any way can avoid the exception�?
0 Kudos
NimeshJarecha
Esri Regular Contributor
Daolin,

Which version of the iOS SDK are you working with?

Regards,
Nimesh
0 Kudos
DaolinShen
New Contributor
thanks Nimesh,

AGS api version 2.0,
ios 4.3



images from web:

NSString* dir = [_allLayersPath stringByAppendingFormat:@"/%@/%@/%@.png",decLevel,hexRow,hexCol];
//NSLog(dir);
_tile.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:dir]]];

it works well until the exception happen.
0 Kudos
NimeshJarecha
Esri Regular Contributor
Daolin,

Do you have all tiles in .png format? As the code you posted expect the tiles to be in png.
Is tile at all levels available in your cache? or there are missing tiles?

Regards,
Nimesh
0 Kudos
DaolinShen
New Contributor
thanks Nimesh,


code.


OfflineTiledLayer : AGSTiledLayer
...

- (NSOperation<AGSTileOperation>*) retrieveImageAsyncForTile: (AGSTile *) tile{


[super.operationQueue setMaxConcurrentOperationCount:20];
NSLog(@"%d",[super.operationQueue operationCount]);

//Create an operation to fetch tile from local cache
OfflineTileOperation *operation =
  [[OfflineTileOperation alloc] initWithTile:tile
       dataFramePath:_dataFramePath
       target:self
              action:@selector(didFinishOperation: )];
//Add the operation to the queue for execution
    [self.operationQueue addOperation: operation];
    return [operation autorelease];
}

- (void) didFinishOperation: (NSOperation<AGSTileOperation>*)op {

//If tile was found ...
if (op.tile.image!=nil) {
  //... notify tileDelegate of success
 
  [self.tileDelegate tiledLayer:self operationDidGetTile: op];
  NSLog(@"%d",op.tile.level);
}else {
  //... notify tileDelegate of failure
  [self.tileDelegate tiledLayer:self operationDidFailToGetTile: op];
}
}

...

if op.tile.image==nil then the console will print out
2011-09-08 13:50:40.204 zjjt[2940:ca0b] Error happened for tile 0/4/0

this exception can be catched by arcgis ios api and throw out.


now i'm Create a new MapView extend from AGSMapView, and Overwrite some touch Functions


code.

SDLinMapView : AGSMapView

...

- (void) touchesBegan: (NSSet *)touches withEvent: (UIEvent *)event {

[_tiledLyr.operationQueue cancelAllOperations];
[super touchesBegan:touches withEvent:event];

}

- (void) touchesMoved: (NSSet *)touches withEvent: (UIEvent *)event {

[_tiledLyr.operationQueue cancelAllOperations];
[super touchesMoved:touches withEvent:event];

}

...

Until now�?has not been happened.


but 😞

overmuch touchs will cause overmuch Calculates�??how to cancel the useless operations �?it Will affect the efficiency.
0 Kudos