UPcload / FitAnalytics-WebWidget-iOS

FitAnalytics WebWidget SDK for iOS
MIT License
4 stars 5 forks source link

WebView initialization gets waiting forever #9

Open mrrubinos opened 5 years ago

mrrubinos commented 5 years ago

We can't initialize properly our FitAnalytics interface in our iOS app. It gets stuck after receiving the "__init" message from the embedded JS widget, so our app keeps waiting for the "load" message forever and our FitAnalytics user interface gets hung in a "loading" state (see attached screenshot).

Our logic follow these steps: 1 - We instantiate a FITAWebWidget by passing a WKWebView/UIWebView component as a parameter, we call [FITAWebWidget load], and then wait to receive a "webWidgetDidBecomeReady" callback from it. 2 - When "webWidgetDidBecomeReady" is called, we respond by calling [FITAWebWidget create:zara-3519100800-I2018 options:]. Then, we receive the "__init" signal from the widget via "webWidgetInitialized" handler/delegate method, but our side keeps waiting for the "webWidgetDidLoadProduct" callback to arrive to take further actions, and this never happens.

The issue seems to be related to iOS 12 and its WKWebView component. We are detecting this issue in some devices updated to iOS 12. If it happens in one device, it happens always in this device. We couldn't reproduce this issue in MacOS device Simulator. If we instantiate a deprecated UIWebView instead and run our App in the same devices, the problem disappears: we receive this "webWidgetDidLoadProduct" callback from the FITAWebWidget and we can now take further actions like "open" or "recommend".

We've attached traces inserted in FITAWebWidget.m file that picture a "working" case (FitAnalyticsTraces_working.txt) and a non-working one (FitAnalyticsTraces_failing).

** Options sent to [FITAWebWidget create:options:] method:

▿ 5 elements ▿ 0 : 2 elements

Useful information:

fitanalytics_interface_gets_hung_loadingstate FitAnalyticsTraces_failing.txt FitAnalyticsTraces_working.txt

tjelen commented 5 years ago

Thank you reporting the issue and providing such detailed description. It took me quite a while to find out what's happening. Eventually I was able to reproduce the issue in the TestRunner app (the test suite), when I added few more widget init&configure scenarios.

It seems that the issue was a straight logic bug in the SDK, which was somehow covered up by the UIWebView, and even using WKWebView it wasn't easy to trigger the bug. The bug fix is included in the latest release (v0.4.3). Please let me know if you still run into problems related to this.

luisqv commented 5 years ago

I can confirm that your latest release (v0.4.3) hadn't fixed this problem. It's still there.