ios - UIDocument & NSFileWrapper Architecture and Performance -


We have recently converted our code to use UID document instead of manipulating files on file system , And we have faced some of the performance issues as a result we are thinking that we are using this class in the wrong way, if someone else has these problems, and the general ways of addressing them What are you

Our App

We have a "Shoe box app" which manages a group of documents, each has several image files that can be quite heavy, a small Metadata file and a short preview image. Users can have multiple documents on their device (1000+ documents). Each document's files are grouped into one directory and we use NSFileWrapper to read and write them.

When our app starts, all the documentation needs metadata to show the document document, and a subset of its preview image is loaded in more detail as the user scrolls.

To get that information, we open all the documents, read their metadata and preview image, if we have to close them, and then reopen on demand.

Problem # 1: Slow loading time

It takes a lot of time to open all documents and read their metadata. I think there are several factors that contribute to this problem: - The open operation of each document is relatively slow - open document blocks and completion blocks are executed on the same line, which greatly damages the latency of operation (mine The document is open, but the completion block needs to wait before the x open document blocks run)

We have a separate index Using il thought to solve this problem, but this approach is to blame that we need to keep in sync with the locations and we file system in case of changes in metadata iCloud files in two.

Issue # 2: Threading

Each open document creates its own "File Access Thread" When we open several documents together, the overhead crushes the app.

We have used this problem to synchronize the open operation by using a semaphore, in this approach it has decreased that it makes the loading even further.

Question
  1. Is there a basic problem with what we are using UIDCOT? If not:
  2. Is anyone getting the same loading problem? What is the common way to solve it? Do other apps contain an index file?
  3. Is there a way to use UI documents in a thread pool? If not, how do you control resource usage?

    Thanks!

    OK, there is no good news here.

    We tried to consult with friends in the industry, using UIDOL's framework and its modified implementation to see if we can improve its performance but it has no use .

    My conclusion is that UIDont is not suitable for this kind of use - it is not ready to support delay and throughput requirements only for open operations. The UID document should be used only when you want to open small files at any moment (very few word processors and drawing applications). It's true that Apple's documentation says, but I think we need to know how serious they are, how serious they are :)

    We use "tricks" to improve some experiences And

    So my recommendation is only:

    1. Your app is like a document based app in nature, which means that you will not have any Time to open more than some documents
    2. There is no need for information inside them so that they can "search" them and show them to the user, or to handle overhead to manage a different index
    3. You can actually auto save / undo / Synchronization / iCloud capability is required

      then use it otherwise consider other solutions

      A side note which is not directly related to the question, but I A public servant As I add: When we needed some major changes in the Uaidiocas the async model app architectures away from direct file access. If you plan to make this step, then evaluate the work that you will need to do carefully.

      Good luck future programmers.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -