Issue with WKWebView on iOS

  • 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.

    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;
    }[/code:31p1yf06]
    
    Correct me if I'm wrong, but shouldn't this plugin be needed when the option was disabled?
    CocoonIO doesn't support this plugin
    
    [quote:31p1yf06]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
    
    
    
    [b]More here:[/b] [url=https://forums.cocoon.io/t/black-screen-issued-when-test-flight-on-ios/2277/20]https://forums.cocoon.io/t/black-screen ... os/2277/20[/url]
    
    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.
    
    [img="https://forums.cocoon.io/uploads/cocoon/original/2X/e/e9848306c42a9d0e3599c157f98cbc7bdf1e8263.png"]
    
    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
    
    [b]Attach a Capx[/b]
    not relevant for this matter
        
    [b]Construct 2 Version ID[/b]
    r227
  • 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.

  • 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

  • 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.

  • 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

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • > 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.

  • Well, I never wanted to use a local webserver because of issues like that (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").

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

    Thank you!

  • 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

  • This is a closed bug report. Please file a new report if you still have trouble. Note WebGL still works without WKWebView.

  • Hi Everyone,

    with r231 you can get your WebGL working on iOS.

    you are able to compile with Cocoonjs cloud (webview+) and get high performance.

    you need export project as cordova

    • uncheck UIWevView
    • uncheck minify

    in Cocoonjs delete plugin Wishlist Cordova

    All works fine (no black screen) except Statuc bar is showing in ois but i think it can be hidden in XCODE

    Hava a good one,

    Sergey

  • Just fix it.... Phonegap dosnt work with audio on iOS +10

    Just..... do it...

  • Hi Everyone,

    with r231 you can get your WebGL working on iOS.

    you are able to compile with Cocoonjs cloud (webview+) and get high performance.

    you need export project as cordova

    - uncheck UIWevView

    - uncheck minify

    in Cocoonjs delete plugin Wishlist Cordova

    All works fine (no black screen) except Statuc bar is showing in ois but i think it can be hidden in XCODE

    Hava a good one,

    Sergey

    Does not work here :/

  • 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

    if you mean that the now official wkwebview plugin for cordova is this https://github.com/apache/cordova-plugi ... iew-engine

    this is not working with c2

    if i add the plugin i got black screen

    if i delete it it work

    if i add it and change the index.html to simple "hello" ... that work ... so i think the problem is in c2 export (c2runtime etc ...)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)