Issue with WKWebView on iOS

Bugs will be moved here once resolved.

Post » Mon Apr 18, 2016 11:03 am

Problem Description
Since the update r226 (I guess) the option "Use WKWebView for iOS" was added to construct 2.
Since that all exports (even if this option is unchecked) for iOS crashes on Cocoon,
because the game needs the Cordova-httpd plugin.


Code: Select all
this.isWKWebView = !!(this.isiOS && this.isCordova && window.indexedDB);
this.httpServer = null;
this.httpServerUrl = "";
if (this.isWKWebView)
{
    this.httpServer = (cordova && cordova["plugins"] && cordova["plugins"]["CorHttpd"]) ? cordova["plugins"]["CorHttpd"] : null;
}


Correct me if I'm wrong, but shouldn't this plugin be needed when the option was disabled?
CocoonIO doesn't support this plugin

It seems that when using the WKWebview Construct2 requires the cordova-httpd plugin to be present to load the data.js otherwise it fails. Not sure why they are doing this but that plugin doesn't work in the Develop app as we read files form other directory than the main Bundle and that plugin tries to get the files from there only.

The only fix I see that you can do is to comment that if (this.isWKWebView) block and let it load the data.js using just xhr.
Quote by the cocoon developer Imanol


More here: https://forums.cocoon.io/t/black-screen ... os/2277/20

So the only way to fix it at the moment is to add !this.isCocoonjs to avoid the crash. But this fix has to be done after each export.

Image

So is there a way to disable the use of the cordova-httpd plugin when the option "Use WKWebView for iOS" is unchecked? Or to implement the fix with !this.isCocoonJs?

Thank you for your time,

Regards
Andy

Attach a Capx
not relevant for this matter

Construct 2 Version ID
r227
Image Image iTunes: Match3 | Google Play: Match3
B
98
S
33
G
30
Posts: 1,117
Reputation: 27,791

Post » Fri Apr 22, 2016 12:59 pm

This is more tricky than it seems, I think. The now-official way to use WKWebView in Cordova is with their new official WKWebView plugin, which is what we use, and requires some workarounds so we include some other plugins such as cordova-httpd. I don't know how Cocoon's WKWebView support works - it seems it uses a different system of their own design. Still it would make sense for them to unify their solution with the way the rest of the Cordova ecosystem works, so I anticipate this will change at some point. The suggested workaround will break it again if they do that. It also makes the runtime think it's in a UIWebView when it's really in a WKWebView, which could have other side-effects.

The HTTP server is only used for video support, since we have to work around WKWebView limitations there. I don't know if Cocoon's own WKWebView support covers video playback? That was a tough problem for us when working with WKWebView. So to hack around this, for the next build I've allowed the runtime to be able to start up without the HTTP server, and the only side effect is video playback probably won't work. I still think the HTTP server plugin should be supported by Cocoon though - otherwise I don't see how video support can work.
Scirra Founder
B
395
S
232
G
88
Posts: 24,368
Reputation: 193,756

Post » Fri Apr 22, 2016 1:35 pm

Ashley wrote:This is more tricky than it seems, I think. The now-official way to use WKWebView in Cordova is with their new official WKWebView plugin, which is what we use, and requires some workarounds so we include some other plugins such as cordova-httpd. I don't know how Cocoon's WKWebView support works - it seems it uses a different system of their own design. Still it would make sense for them to unify their solution with the way the rest of the Cordova ecosystem works, so I anticipate this will change at some point. The suggested workaround will break it again if they do that. It also makes the runtime think it's in a UIWebView when it's really in a WKWebView, which could have other side-effects.

The HTTP server is only used for video support, since we have to work around WKWebView limitations there. I don't know if Cocoon's own WKWebView support covers video playback? That was a tough problem for us when working with WKWebView. So to hack around this, for the next build I've allowed the runtime to be able to start up without the HTTP server, and the only side effect is video playback probably won't work. I still think the HTTP server plugin should be supported by Cocoon though - otherwise I don't see how video support can work.


Hi @Ashley

Thanks for your respond! I forwarded your answer to a ludei developer.
I hope he finds a way to work around it :) So it works again without the workaround provided by me above.

Thank you so much!

Regards
Andy
Image Image iTunes: Match3 | Google Play: Match3
B
98
S
33
G
30
Posts: 1,117
Reputation: 27,791

Post » Thu Apr 28, 2016 7:59 am

@Ashley

I just wanted to report that this incompatibility means that CocoonIO is no longer compatible with C2 games for WKWebView.

I have contacted CocoonIO requesting a refund for my subscription and they have confirmed they cannot do anything about it since C2 is at fault for not supporting their service. -_-

Now, if Cordova's preferred method is the correct one, then obviously CocoonIO's is the "hack/work-around" and it's their fault... either way, this is a major problem moving forward for any iOS developer that wants to use CocoonIO. Basically, they are stuck with crap Canvas+ or worse WebView.

@AndreasR

That work-around doesn't work anymore, it disables WKWebView and defaults to Webview mode only.

/facepalm

ps. I've been testing Intel XDK WKWebView and so far it's functional, though there's major issues with audio/music. But at least it works.
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Thu Apr 28, 2016 8:42 am

Silverforce wrote:@Ashley

I just wanted to report that this incompatibility means that CocoonIO is no longer compatible with C2 games for WKWebView.

I have contacted CocoonIO requesting a refund for my subscription and they have confirmed they cannot do anything about it since C2 is at fault for not supporting their service. -_-

Now, if Cordova's preferred method is the correct one, then obviously CocoonIO's is the "hack/work-around" and it's their fault... either way, this is a major problem moving forward for any iOS developer that wants to use CocoonIO. Basically, they are stuck with crap Canvas+ or worse WebView.

@AndreasR

That work-around doesn't work anymore, it disables WKWebView and defaults to Webview mode only.

/facepalm

ps. I've been testing Intel XDK WKWebView and so far it's functional, though there's major issues with audio/music. But at least it works.


Hi,

the fix only works when you have unchecked "Use WKWebView for iOS", because c2 still needs the cordova httpd plugin, even when this checkbox was unchecked. I'm in touch with the cocoon developer.

I'll keep you posted about this matter.

I hope ludei and scirra find a solution, so that it works again...

Regards
Andy
Image Image iTunes: Match3 | Google Play: Match3
B
98
S
33
G
30
Posts: 1,117
Reputation: 27,791

Post » Thu Apr 28, 2016 9:21 am

Silverforce wrote:@Ashley

I just wanted to report that this incompatibility means that CocoonIO is no longer compatible with C2 games for WKWebView.

Are you sure? If there is a normal Cordova build option which uses cordova-ios 4.0+, it should switch to WKWebView if you tick the option in C2, regardless of what they call that option. I don't know how Ludei's build system works though, it seems different to everything else.
Scirra Founder
B
395
S
232
G
88
Posts: 24,368
Reputation: 193,756

Post » Thu Apr 28, 2016 9:59 am

Ashley wrote:
Silverforce wrote:@Ashley

I just wanted to report that this incompatibility means that CocoonIO is no longer compatible with C2 games for WKWebView.

Are you sure? If there is a normal Cordova build option which uses cordova-ios 4.0+, it should switch to WKWebView if you tick the option in C2, regardless of what they call that option. I don't know how Ludei's build system works though, it seems different to everything else.


This is what CocoonIO tech support said to me:

"Yes, we have seen that but as far as we know it only affects to Webview+, Canvas+ still works as before. There is not much we can do, Cocoon and C2 are different products and technically is not possible for us to fullfill current C2 requirements for Webview+. A possible solution has been reported here: https://forums.cocoon.io/t/black-screen ... os/2277/19 in can you want to give it a try."

That work-around solution involves editing the .js file and it does not work with WKWebView that they implement.

I've tried it, does not work.

There's also this other problem with their WKWebView plugin:

https://forums.cocoon.io/t/cordovalocal ... com/1544/9

Basically no C2 exported game can be made with CocoonIO with Webview+ (WKWebview) anymore.
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,614

Post » Thu Apr 28, 2016 10:24 am

Well, I never wanted to use a local webserver because of issues like that :P (as well as the problem of port conflicts vs. same-origin storage)

I think the best solution is for Cocoon to adopt the official Cordova WKWebView support which C2 (and the rest of the Cordova ecosystem AFAIK) is designed to use. I can't see a good long-term solution right now other than hacks which will trip things up again later down the road (like "pretend to not be a WKWebView even if it really is just to make Cocoon.io happy for the time being until they update which will break it again").
Scirra Founder
B
395
S
232
G
88
Posts: 24,368
Reputation: 193,756

Post » Wed Jun 01, 2016 2:27 pm

Any solution until now for the blackscreen? I also experiencing this on emulate tab.

Thank you!
B
14
S
5
Posts: 110
Reputation: 1,338

Post » Fri Jul 15, 2016 3:37 pm

Hi Everyone,

Please advise if any solutions were found on this issue?

My game really needs to use WebGL in iOS otherwise performance is unplayable.

If you have any other solution please share the knowledge

Thank you,

Sergey
B
19
S
6
G
1
Posts: 25
Reputation: 1,719

Next

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest