apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 988 forks source link

Issues on iOS 12 for apps using OpenUI5 #1080

Closed tylervz closed 3 years ago

tylervz commented 3 years ago

Bug Report

Problem

Since upgrading to cordova-ios 6.2.0 from 5.1.1 I'm facing several issues when running my app, which uses the OpenUI5 framework, on iOS 12. I have created a sample app to demonstrate the issues:

https://github.com/tylervz/ui5-cordova-ios-sample-app

What is expected to happen?

Launch the app on an iOS device (emulator or actual device) running iOS 12.4. I believe the issues would happen with any 12.x version of iOS; 12.4 is highest so I've been testing with that on an emulator.

Press the Show Today's Date button. Instead of showing a toast with today's date, the page appears to refresh. This is the JavaScript line that's not executing as expected:

DateFormat.getDateTimeInstance({ pattern: "yyyy-MM-dd HH:mm:ss.S" });

Press the Filter icon button at the top right of the home page. Instead of showing the Dialog with a sap.m.DatePicker, the page appears to refresh. If you were to remove the DatePicker from the dialog and the corresponding code in the controller, the dialog would open fine on iOS 12.

Press the Go To Detail Page button. The app crashes rather than showing the page with a sap.ui.unified.Calendar.

If you run the app on Android or a different iOS version, the app behaves as expected (with a couple exceptions noted in my README for iOS 11). Additionally, if you checkout the working branch, you can run the app on iOS 12.4 and navigate to the Detail Page without the app crashing because the page does not have the sap.ui.unified.Calendar control on it.

Information

Command or Code

Clone my sample app.

git clone git@github.com:tylervz/ui5-cordova-ios-sample-app.git
cd ui5-cordova-ios-sample-app
cordova plaftorm add ios
cordova build ios
open platforms/ios/HelloWorldUI5.xcodeproj

Then run the application from XCode using an emulator running iOS 12.4

Environment, Platform, Device

The app displays issues on an iOS 12.4 iPhone 8 emulator.

However it runs fine on the following devices: iOS 11.3 iPhone 8 emulator iOS 13.5 iPhone 8 emulator iOS 14.4 iPhone 8 emulator Android 8.0.0 (Samsung Galaxy S7) with Chrome 84.0.4147.125 (OK).

Version information

OpenUI5 version: 1.80.0 Cordova version: 10.0.0 cordova-ios version: 6.2.0 macOS 10.15.7 Xcode 12.4

Checklist

breautek commented 3 years ago

This doesn't appear to be a cordova bug. So I'll be closing this issue.

I tried clicking on "Show Today's Date" which produces the following error:

failed to load JavaScript resource: sap/ui/demo/basicTemplate/Component-preload.js -  sap.ui.ModuleSystem

There is no sap folder, let alone a path that looks like that in your bundled resources.

There are several other similar errors as well, such as failing to load:

app://localhost/i18n/i18n_en_US.properties

which again, there is no such file in your asset bundle. There is a /i18n/i18n.properties however.

If I click on Open Details Page, it goes into an endless loop, also related to it trying to load a file that doesn't exist or isn't bundled in your web assets.

My best advice is to ensure that everything is copied into your www folder as required by the framework.

tylervz commented 3 years ago

Thank you for taking the time to look into this @breautek .

The following error

failed to load JavaScript resource: sap/ui/demo/basicTemplate/Component-preload.js -  sap.ui.ModuleSystem

is actually produced before you click on "Show Today's Date"; it's produced when the applications loads. That error is present even when the application is running without an issue, as you can see when running the app on iOS 14. OpenUI5 by default attempts to load a preload file before fetching individual controller and view files, but it does not need a preload file to run.

Likewise, with the similar error of this resource request failing to load with a 404:

app://localhost/i18n/i18n_en_US.properties

That error is present even when the application is running without an issue (on iOS 14) because OpenUI5 attempts to load the most specific i18n file it can for the user and then falls back to /i18n/i18n.properties. /i18n/i18n.properties is successfully being used by the app to provide translations of text.

I agree that the issues documented in my sample app are most likely due to the application trying to load a file that doesn't exist or isn't bundled in the web assets; it's just not clear which specific file is the issue, since it cannot be the ones mentioned above. And it's also puzzling why the app is able to load this file when running on iOS 11, 13 and 14.

tylervz commented 3 years ago

I want to follow up here in case anybody else experiences the same issues I was running in to. As I explained in the GitHub issue I opened with OpenUI5, I discovered that loading OpenUI5 from the CDN (rather than loading it from local files) resolves all the issues I was having in the Cordova app.

<script id="sap-ui-bootstrap"
    src="https://openui5.hana.ondemand.com/1.85.4/resources/sap-ui-core.js"
    data-sap-ui-theme="sap_fiori_3"
    data-sap-ui-resourceroots='{
        "sap.ui.demo.basicTemplate": "./"
    }'
    data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"
    data-sap-ui-compatVersion="edge"
    data-sap-ui-async="true"
    data-sap-ui-frameOptions="trusted">
</script>

On the cdn branch of my sample application, you can run it and see for yourself. So the solution we're going to use in our actual app is to add the sap-ui-bootstrap script tag dynamically with JavaScript when deviceready fires. If the app is running on iOS 12, we will set src to the CDN i.e. "https://openui5.hana.ondemand.com/1.85.4/resources/sap-ui-core.js" and otherwise we will set src to a local sap-ui-core.js file.