• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

air 26 stagewebview - some breaking changes

Participant ,
Jun 27, 2017 Jun 27, 2017

Copy link to clipboard

Copied

Hello,

I just updated from AIR SDK 24 to 26 as I had some issues with StageWebView on iOS.

But now I am having more issues:

- On desktop (windows), setting StageWebView(true) makes javascript misbehave, like functions not triggering.

- On both iOS and Windows, stage webview does not fire the Complete event anymore (it works fine on Android). So I am unable to know if a page has loaded or not

- Calling a javascript function via loadURL("javascript:functionname();") does not work anymore on iOS and Desktop.

TOPICS
Air beta

Views

5.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 27, 2017 Jun 27, 2017

Copy link to clipboard

Copied

It's strange because I use stageebview intensively (with bi-directionnal communication) and for me the complete event is fired on windows, ios and android. Javascript call is working as well on the three platforms.

I didn't try StageWebView(true) on desktop tho.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 28, 2017 Jun 28, 2017

Copy link to clipboard

Copied

It started to happen with AIR26 - AIR 24-25 work fine.

I guessed it was related to WKWebView as on Android it is working fine.

I am not sure what changed in the desktop implementation that also broke it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

Are you using AIR 26+ ?
The issue is only with AIR 26 + and completely breaking

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 28, 2017 Jun 28, 2017

Copy link to clipboard

Copied

Hi, I don't know, but this might be related to AIR 26 using WKWebView (instead of UIWebView) behind the scene, for StageWebView. You can read about executing JavaScript here: https://developer.apple.com/documentation/webkit/wkwebview

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 24, 2017 Jul 24, 2017

Copy link to clipboard

Copied

   Using AIR 26 build 119.  or. build 118.   It started to happen on iOS.

   I will

          webview.loadURL("http://.../media/media.html");

         calling a javascript function via loadURL("javascript:functionname();") do work。

  I will

  var strpath:String = "app:/html/media.html";

  var path:String = new File(new File(strpath).nativePath).url;

  webView.loadURL(path);

    calling a javascript function via loadURL("javascript:functionname();") do not work。

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jul 26, 2017 Jul 26, 2017

Copy link to clipboard

Copied

Hi,

Issue is not reproducible at our end please share a sample project with us.

Regards,

Adobe AIR Team

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 27, 2017 Jul 27, 2017

Copy link to clipboard

Copied

Hi:

I tried a new method yesterday。

private var webView:StageWebViewBridge = null;

webView.addEventListener(flash.events.Event.COMPLETE,oncomplete);

protected function oncomplete(event:flash.events.Event):void

{

//add delay 2seconds, do work.

mytime.reset();

mytime.delay=2000;

mytime.repeatCount = 1;

mytime.start();

}

protected function ontimecomplete(event:TimerEvent):void

{

var strpath1:String = "app:/html/test.mp4";

var path1:String = new File(new File(strpath1).nativePath).url;

var path:String = "[{\"url\":\""path1"\",\"head\":\"\"}]";

webView.call("fnCalledFromAs3",null,path);

}

calling a javascript function via loadURL("javascript:functionname();") do work。

But have a question.

My webview have video

H5 video. is playing. app:/html/test.mp4; do work。

H5 Video。 playing "file:///var/mobile/Containers/Data/Application/512EC30D-B01A-47CB-88E2-912F6CED3102/Library/Application Support/starq.game.xbb/Local Store/mov/qb707.mp4" ; do not work.

I used the test

var f:File =new File("file:///var/mobile/Containers/Data/Application/512EC30D-B01A-47CB-88E2-912F6CED3102/Library/Application Support/starq.game.xbb/Local Store/mov/qb707.mp4");

f.exists is true.

If you have experience in this field, please let me know,thanks.

Regards.

Richard Chen.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 02, 2017 Aug 02, 2017

Copy link to clipboard

Copied

Hi Richard,

We use file:// in a different way. The above mentioned way will not work. Please go through the forum issue and you will find the different solutions. Please revert back if this doesn't help you.

StageWebView for Local HTML file

Regards,

Adobe AIR Team

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 11, 2017 Aug 11, 2017

Copy link to clipboard

Copied

Hi, I checked the links in the StageWebView for Local HTML file. The links from within that thread are from 2 years ago and they do not work for AIR26+. Local HTML cannot be loaded from either documentsDirectory nor applicationStorageDirectory.

stagewebview.loadURL(path) returns an error - not able to reach location:[ErrorEvent type="error" bubbles=false cancelable=false eventPhase=2 text="The operation couldn't be completed. (kCFErrorDomainCFNetwork error 1.)" errorID=3228]

I tried using both ways to get the file path and both returned the above error. It just cannot find the location of the files saved locally -

1.

var destination:File = File.documentsDirectory.resolvePath("29/index.html");

var fp = destination.nativePath;

path = "file://" + fp;

webView.loadURL(path);

2.

var destination:File = File.documentsDirectory.resolvePath("29/index.html");

path = new File(destination.nativePath).url;

webView.loadURL(path);

I even tried with changing url file scheme to "file://", "file:///", and "file:////" and none of them find the files saved in documentsDirectory from AIR26 and AIR 27 beta. The code worked for AIR 25 and below.

I tried loading the html from applicationStorageDirectory and it cannot find the html files either.

I am confused why the same exact code worked for AIR 25 and below but stopped working since AIR 26.

I have searched all over the place and can't find any real answers.

Please provide some help and solutions/workaround.

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 23, 2017 Aug 23, 2017

Copy link to clipboard

Copied

Thanks for reporting the issue, we are investigating it.

Regards,

Adobe AIR Team

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 13, 2017 Sep 13, 2017

Copy link to clipboard

Copied

This issue is same in Air ver 27.0.0.124 released on September 12, 2017.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 03, 2018 Oct 03, 2018

Copy link to clipboard

Copied

LATEST

I guess you didn't check this out. Just try to open complex web content with ref to subdirectories

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Nov 30, 2017 Nov 30, 2017

Copy link to clipboard

Copied

Any updates?

Air 28.0.0.120 can load file://...../index.html

But index.html can't load images and css <link href="style.css" rel="stylesheet">.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Feb 19, 2018 Feb 19, 2018

Copy link to clipboard

Copied

Hi,

This issue has been fixed. Please give it a try with AIR 29 Beta from Download Adobe AIR 29 Beta - Adobe Labs.

Thanks,

Pravishti | Adobe AIR Engineering

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 28, 2018 Mar 28, 2018

Copy link to clipboard

Copied

Hello,

Tested on iOS 10.3.3 and iOS 11.2.5 with AIR 29

I was able to load the locally created file (from File.cacheDirectory) into the StageWebView.

(basically I'm using StageWebViewBridge modified a little to avoid all those javascript calls)

However, everything works just fine with the HTML and CSS, but not for JS files included inside the generated HTML file.

Just for your information, I'm also using Away3D in my project, and I'm loading .awd files from the same "cacheDirectory" (differnet folder). No matter if I ask for File or FileReference permissions on startup, .awd files just won't load inside the View3D scene.

Project Setup:

- Robotlegs 1.5.2

- Starling 2.2

- Feathers 3.3.0

- Away3D 4.1.6

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2018 Mar 29, 2018

Copy link to clipboard

Copied

More info I found here:
https://medium.com/glose-team/custom-scheme-handling-and-wkwebview-in-ios-11-72bc5113e344

UIWebView support custom NSURLProtocol, it means that in order to provide a custom way to load a custom url scheme, you simply had to create a subclass of NSURLProtocol and then register your class with NSURLProtocol. Then anything calling your custom scheme (like helloworld://) would invoke your custom NSURLProtocol class. Then you’re responsible for loading and forwarding your content. This is very powerful, and in our case we use it to load various assets within a book, such as images, videos etc… So a total no go if we can’t do that. There is a lot of workaround we could have used, but they were mostly hacks, and not really ok for a production application.

WKWebview doesn’t support custom NSURLProtocol, so you can register any classes you want, it’ll never be called because of a WKWebView requests. Well REJOICE ! In iOS 11 Apple added WKURLSchemeHandler. It works almost the same as NSURLProtocol!

So that's why JS call to AS3 doesn't work - since AIR 29 is packed with iOS 10, and we will have it working when we get AIR version with iOS 11 packed I think...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 29, 2018 Mar 29, 2018

Copy link to clipboard

Copied

I don't get it, I use JS call to AS3 through LocationChangeEvent.LOCATION_CHANGING and it works perfectly. Param transmission with url is endless if you do it well. There are few tricks but I use it for ages on iOS and Android (production).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 01, 2018 Apr 01, 2018

Copy link to clipboard

Copied

I Met the same problem too...Now I am using the AIR SDK 25, it is OK. If using air sdk 26 and above, the html+js  do not work, and it is difficute to debug. @shiew43971953 I saw you said "basically I'm using StageWebViewBridge modified a little to avoid all those javascript calls", I use StageWebViewBridge too. Would you like to share what you modified in StageWebViewBridge? thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 01, 2018 Apr 01, 2018

Copy link to clipboard

Copied

Sure, here is the thing...

In able to communicate - StageWebViewBridge use custom scheme as url calls in browser (UIWebView - up to AIR 25).

If you open the StageWebViewBridge.js  and StageWebViewDisk.as files you'll find:

  • var sendingProtocol = checker.iphone ? 'about:' : 'tuoba:'; (~ line 58 in JS file)
  • public static const SENDING_PROTOCOL : String = isIPHONE ?  "about:" : "tuoba:"; (~ line 24 - in AS3 file)

So, when you want to call function from JS to AS3 - you create "callback" method which means that you send some data from JS to AS3 (like method name, and string data - all packed in one JSON) - and this call in iOS browser (address bar) looks like:

  • about:QwifnserWFInFROIHRa3340==   -> (some Base64 string converted from JSON object)

Now, from AIR 26 and above with new iOS framework packed (iOS 10) we cannot use UIWebView for browser engine in our apps, so custom URI Schemes are not supported anymore, but we can use new WKWebView that Apple provide for (mostly) hybrid applications - which use 90% web views inside the apps. In many cases WKWebView is better then UIWebView since as developer - you need more control on what is inside the web part - using handlers. But, unfortunately for us (using AIR 26 to AIR 29) we don't have all these handlers (such as handler for custom URI scheme like in our case) available inside the AIR SDK, and we still have the ONLY handler LocationChange.


Unsuccessful try:
- If you change ('about:' : 'tuoba:') to ("custom-scheme:" : "custom-scheme:") - you'll get browser to work - but without any communication from JS to AS3 (AS3 to JS will work)

Fix:
I manage to exclude StageWebViewBridge from my project totally (just switch all the views on StageWebView instead), and now I go through all the HTML pages that I generate on creation complete, and add extra JavaScript call like:

     function doSomethingInAS3(data){

          var base64 = btoa('{"method":"doSomethingInAS3", "data":"'+ data +'"}'); // convert JSON to Base64

          window.location.href = "?"+ base64;

      }

And in AS3 I parse the href like:

     protected function locationChangingHandler(event:flash.events.Event):void{

          var obj:Object;

          var loc:String = (event as LocationChangeEvent).location;

          var arr:Array = loc.split("?");

          if(arr.length > 1){

               obj = com.adobe.serialization.json.JSON.decode(Base64.decode(String(arr[1])).toString());

          }

          .......

          // now in "obj" you have 2 parameters: obj.method, and obj.data from JS json

     }

If you want to call function from AS3 to JS - you can avoid Base64 conversion in most cases like:
     webView.loadURL("javascript:doSomethingInJavaScript(false, 57, 'my string')");

In other words communication now works without custom URI scheme but with direct call "javascript" on browser.

Note:

Be aware that when testing on Windows (desktop) you'll want to call:

     webView.loadURL("javascript:void(0)");

after each "locationChangingHandler" event... just to reset the browser, and make available next JS to AS3 call.

I think you got the idea
Cheers!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 03, 2018 Apr 03, 2018

Copy link to clipboard

Copied

Thank you for such a detailed explanation. I will have a try. thanks again.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 03, 2018 Apr 03, 2018

Copy link to clipboard

Copied

Yep this is the code I use for ages:

private function locationChanging(e:LocationChangeEvent):void {

     e.preventDefault();

     trace("WF locationChanging", e.type, e.location, e.location.split("?")[1]);

     var params:String = e.location.split("eventer.java?")[1];

     if(!params || params == "") return;

     var json:String = Base64.decode( params ).toString();

     trace("WF locationChanging json", json);

     var vars:Object = JSON.parse( unescape(json) );

     if(!vars) return;

     if(vars.hasOwnProperty("modal")) modal = vars.modal;

     ...

Don't forget the preventDefault otherwise you will have problems, unless you want some urls to pass through

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 03, 2018 Apr 03, 2018

Copy link to clipboard

Copied

and this is my JS code:

        function callAS3(jvars) {

            setTimeout(function() {

              var href = "about://eventer.java?" + window.btoa(encodeURIComponent(jvars));

                document.location.href = href;

            }, 0);

        }

Then call:

callAS3(JSON.stringify({back:'all'}));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines