cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Fiori for iOS SDK - OData requests slow performance

Former Member
0 Kudos

Hi everyone,

We are developing a Native iOS app using the SAP Fiori for iOS SDK 2.0. The app is offline enabled according to the tutorials available here. However, when we execute an OData request to the backend, while the device is online, the response is very slow, even for small entity sets. I suspect that the delay is in the opening of the offline store or in the download step. Is there any setting that I am missing that slows down the online requests?

When the device is offline - the performance is much better - as expected, since it is querying the data locally. The performance is also good when performing the online request directly - without opening the offline store. The code is similar to the example found in the tutorial:

func requestEntities(completionHandler: @escaping (Error?) -> Void) {
    // Only request the first 20 values. If you want to modify the requested entities, you can do it here.
    deliveryServiceOffline.open { error in
        guard error == nil else {
            return;
        }


        self.appDelegate.isStoreOpened = true


        self.deliveryServiceOffline.download { error in
            guard error == nil else {
                let query = DataQuery().selectAll().top(20)
                self.deliveryServiceOffline.fetchPackages(matching: query) { packages, error in
                    guard let packages = packages else {
                        completionHandler(error!)
                        self.appDelegate.closeOfflineStore()
                        return
                    }
                    self.entities = packages
                    completionHandler(nil)
                    self.appDelegate.closeOfflineStore()
                }
                return
            }


            let query = DataQuery().selectAll().top(20)
            self.deliveryService.fetchPackages(matching: query) { packages, error in
                guard let packages = packages else {
                    completionHandler(error!)
                    self.appDelegate.closeOfflineStore()
                    return
                }
                self.entities = packages
                completionHandler(nil)
                self.appDelegate.closeOfflineStore()
            }
        }
    }
}


If you have any ideas on why this is happening, I'd appreciate any input.

Thank you very much in advance!

Accepted Solutions (1)

Accepted Solutions (1)

aschlosser
Employee
Employee

Nikola,

The demo/tutorial code is trying to explain in very compact form the different lifecycle and data access methods that you need to invoke when building offline apps. In a real app, you really shouldn't do the `download` every time you try accessing data. I presume this is what causes the performance hit that you observe.

In a real app you want to refactor this a bit and find the appropriate place to do the data upload/download where appropriate. This might be at different occasions, depending on your scenario - maybe every time the app starts, every time the app goes online, or only if the user presses a 'sync' button. So, this boils down to opening the store when the app starts, doing a download/upload when appropriate (but rarely), and closing the store when the app stops.

Hope that helps.

Thanks
Andreas

Former Member

Hi Andreas,

Thanks for the clarification and clear answer. This makes a lot of sense, and helps us a lot! As a general feedback, maybe it would be nice to include this in the tutorials, as right now I found it not so clear 🙂

Thank you very much!

Regards,

Nikola

Answers (0)