Cannot create large number of layers on iOS

991
4
Jump to solution
02-05-2020 06:14 AM
MichalStolba
New Contributor II

I need to create large number (hundreds) of custom ImageTiledLayer layers which use locally stored tiles. It works fine on desktop (Linux) and Android, but crashes on iOS. It turned out, that the cause of the crash is that the app has too many open file handles, as on iOS the limit is typically fairly low (e.g., 256). The app crashes when opening around 190 layers.

I have a couple of questions:

- Can anyone confirm this is really the case? Is the ImageTiledLayer keeping open file handlers?

- If so, can we somehow determine how many? Is it one per tile, or one per layer?

- Also is there any way how to force the layer to close the file handlers after loading the tiles?

Best Regards,

Michal Stolba

0 Kudos
1 Solution

Accepted Solutions
JamesBallard1
Esri Regular Contributor

Michal Stolba‌,

>Can anyone confirm this is really the case? Is the ImageTiledLayer keeping open file handlers?

   Yes, ImageTiledLayer will keep open file handles but I cannot confirm that is the exact problem you are hitting. Can you post any stack trace or logging messages?

We have seen messages like this before in cases like this.

Error: code = 1, TIFFOpen:/Users/James/Raster/renderer/rgb/po_311944_pan_0000001.tif: Too many open files

Can you let us know if you see anything like that?

>- If so, can we somehow determine how many? Is it one per tile, or one per layer?

I don't have a specific number I'm afraid.

>- Also is there any way how to force the layer to close the file handlers after loading the tiles?

That can be tricky. If you can force the objects to destruct, it can release the file handles. That can be done in our C++ API, but is much trickier in the QML Api due to garbage collection and not being able to deterministically destroy objects.

A potential alternate workflow would be to limit the scale range of layers to a specific extent so it will not attempt to load so many tiles at the same time as you pan/zoom the map. That may give a better chance at success.

View solution in original post

4 Replies
JamesBallard1
Esri Regular Contributor

Michal Stolba‌,

>Can anyone confirm this is really the case? Is the ImageTiledLayer keeping open file handlers?

   Yes, ImageTiledLayer will keep open file handles but I cannot confirm that is the exact problem you are hitting. Can you post any stack trace or logging messages?

We have seen messages like this before in cases like this.

Error: code = 1, TIFFOpen:/Users/James/Raster/renderer/rgb/po_311944_pan_0000001.tif: Too many open files

Can you let us know if you see anything like that?

>- If so, can we somehow determine how many? Is it one per tile, or one per layer?

I don't have a specific number I'm afraid.

>- Also is there any way how to force the layer to close the file handlers after loading the tiles?

That can be tricky. If you can force the objects to destruct, it can release the file handles. That can be done in our C++ API, but is much trickier in the QML Api due to garbage collection and not being able to deterministically destroy objects.

A potential alternate workflow would be to limit the scale range of layers to a specific extent so it will not attempt to load so many tiles at the same time as you pan/zoom the map. That may give a better chance at success.

MichalStolba
New Contributor II

Hi James,

thank you for confirmation. Yes, it is the problem we are hitting, there is a 256 open file limit on iOS (we are testing on), the app crashes around 190 created layers and does not crash when we limit the number of created layers.

The error we are getting (from Qt) is:

QThreadPipe: Unable to create pipe: Too many open files QEventDispatcherUNIXPrivate(): Can not continue without a thread pipe

It seems that removing previously created layers from the map operational layers helps.

Our usecase is somewhat non-standard, we have just a single zoom-level and quite restricted area, but we have a lot of time-dependent and elevation-dependent layers. I was wandering whether it is possible to tell the layer to load all tiles and close the file handle, but I guess this is too much to ask from the QML/Qt API.

Cheers,

Michal

0 Kudos
JamesBallard1
Esri Regular Contributor

Thanks for confirming the problem with the error message.

Another potential option for you would be to implement a legend with visibility toggles to switch layers on and off.

arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_CppSamples/Layers/ChangeSublayerVisibility at 37f29d363... 

arcgis-runtime-samples-qt/ArcGISRuntimeSDKQt_QMLSamples/Layers/ChangeSublayerVisibility at 78dd6bd4f... 

Using that method you could control how much was displayed at any given time. That might also help, but unfortunately we do not have any way to programmatically release the open file handles.

0 Kudos
MichalStolba
New Contributor II

Thank you. We partially do that as well.

0 Kudos