AGSZipException occurs when using retrieveImageAsyncForTile, crashing application

588
6
06-20-2012 11:10 AM
JasonScharf
New Contributor III
Hi,

I'm using an AGSLocalTiledLayer to extract numerous tiles from a TPK package. I'm able to extract a number of tiles but after requesting some the application crashes saying it cannot open by TPK file.

The exception thrown is an AGSZipException and it is thrown at AGSZipFile.m line 83.

My call stack looks like this:

AGSZipFile initWithFileName
AGSFileStream initWithPath
AGSFileStream fileStreamForReadingAtPath
AGSVFileReader open
...
AGSLocalTileRequestOperation main

I am dispatching my tile requests one at a time and waiting the the requests to complete before proceeding.

Why do I get an exception that the TPK can't be opened after I have successfully fetched many tiles?
Can someone tell me what is the specific error condition causing this exception?
Is there any way I can trap this exception so it at least does not bring down my entire app?


Thanks,
Jason
0 Kudos
6 Replies
JasonScharf
New Contributor III
OK, so the 128th call to retrieveImageAsyncForTile crashes the application every time.

Examining an IO trace shows the TPK file being opened and read, but not closed.

Either the TPK file is mistakenly being re-opened by the local tile layer many times, or it is simply not being closed properly.
0 Kudos
NimeshJarecha
Esri Regular Contributor
If possible, could you please post the tpk file and a crash dump so we can look at the issue?

Regards,
Nimesh
0 Kudos
JasonScharf
New Contributor III
Hi Nimesh,

The TPK is probably too large to post here, but I'll try and get a crash dump for you.

I can confirm that the problem is the TPK file being opened every time retrieveImageAsyncForTile is called, leading to an exhaustion of file handles.

The only time that the TPK file is closed is when the AGSLocalTileRequestOperation is disposed. I have verified this by manually disposing it. Manually disposing it is not an option, of course, because it is owned by the API.

My question now is this: Does the map itself use retrieveImageAsyncforTile to fetch tiles, or some other method when using AGSLocalTiledLayer? If an alternate, private method is used, would it be possible to post the signature of the method so I can invoke it?


Thanks!
0 Kudos
EricIto
New Contributor III
Hi Nimesh,

The TPK is probably too large to post here, but I'll try and get a crash dump for you.

I can confirm that the problem is the TPK file being opened every time retrieveImageAsyncForTile is called, leading to an exhaustion of file handles.

The only time that the TPK file is closed is when the AGSLocalTileRequestOperation is disposed. I have verified this by manually disposing it. Manually disposing it is not an option, of course, because it is owned by the API.

My question now is this: Does the map itself use retrieveImageAsyncforTile to fetch tiles, or some other method when using AGSLocalTiledLayer? If an alternate, private method is used, would it be possible to post the signature of the method so I can invoke it?


Thanks!


Do I understand correctly: you are manually kicking off tile requests? If so, this is not how the AGSLocalTiledLayer is intended to be used. You should just instantiate it and add it to the map. The map will handle retrieving the tiles and closing the file handle when needed.

Eric
0 Kudos
JasonScharf
New Contributor III
Hi Eric,

I'm using it to pull out a number of tiles from a TPK, I don't necessarily need the map. What I need is the tiles. How does the map fetch tiles from the layer? Does it use retrieveImageAsyncForTile or some other undocumented method?

Thanks
0 Kudos
JasonScharf
New Contributor III
OK, I found the issue. Some of my tile requests were not coming from the main thread and this is what was causing the leak.
0 Kudos