Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with cordova-plugin-crosswalk-webview #32

Open
jfrumar opened this issue Feb 9, 2016 · 7 comments
Open

Doesn't work with cordova-plugin-crosswalk-webview #32

jfrumar opened this issue Feb 9, 2016 · 7 comments

Comments

@jfrumar
Copy link

jfrumar commented Feb 9, 2016

This plugin appears to be working on Android with the system WebView, however fails when using a Crosswalk webview.

It looks like casting a CordovaWebViewEngine.EngineView to a WebView is not possible and results in an exception.

02-09 12:38:24.063 16211 16288 W System.err: java.lang.ClassCastException: org.crosswalk.engine.XWalkCordovaView cannot be cast to android.webkit.WebView 02-09 12:38:24.064 16211 16288 W System.err: at com.phonegap.plugin.mobileaccessibility.DonutMobileAccessibilityHelper.initialize(DonutMobileAccessibilityHelper.java:51) 02-09 12:38:24.064 16211 16288 W System.err: at com.phonegap.plugin.mobileaccessibility.JellyBeanMobileAccessibilityHelper.initialize(JellyBeanMobileAccessibilityHelper.java:42) 02-09 12:38:24.064 16211 16288 W System.err: at com.phonegap.plugin.mobileaccessibility.KitKatMobileAccessibilityHelper.initialize(KitKatMobileAccessibilityHelper.java:40) 02-09 12:38:24.064 16211 16288 W System.err: at com.phonegap.plugin.mobileaccessibility.MobileAccessibility.initialize(MobileAccessibility.java:64) 02-09 12:38:24.064 16211 16288 W System.err: at org.apache.cordova.CordovaPlugin.privateInitialize(CordovaPlugin.java:54) 02-09 12:38:24.064 16211 16288 W System.err: at org.apache.cordova.PluginManager.getPlugin(PluginManager.java:169) 02-09 12:38:24.065 16211 16288 W System.err: at org.apache.cordova.PluginManager.exec(PluginManager.java:120) 02-09 12:38:24.065 16211 16288 W System.err: at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59) 02-09 12:38:24.065 16211 16288 W System.err: at org.crosswalk.engine.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40) 02-09 12:38:24.065 16211 16288 W System.err: at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method) 02-09 12:38:24.065 16211 16288 W System.err: at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53) 02-09 12:38:24.065 16211 16288 W System.err: at android.os.Handler.dispatchMessage(Handler.java:102) 02-09 12:38:24.065 16211 16288 W System.err: at android.os.Looper.loop(Looper.java:148) 02-09 12:38:24.065 16211 16288 W System.err: at android.os.HandlerThread.run(HandlerThread.java:61)

majornista added a commit that referenced this issue Feb 11, 2016
Use reflection for getView, getSettings, getTextSize/getTextZoom, and
setTextSize/setTextZoom so that the View does not need to be cast as an
android.webkit.WebView.
@majornista
Copy link
Collaborator

@jfrumar Give it a try now to see if using reflection for getView, getSettings, getTextSize/getTextZoom, and setTextSize/setTextZoom so that the View does not need to be cast as an android.webkit.WebView allows plugin to be compatible with XWalkView and XWalkSettingsInternal.

@hkvstore
Copy link

hkvstore commented Mar 7, 2016

Have the same problem with CrossWalk, It seems that the changes still do not solve the problem.

@majornista
Copy link
Collaborator

@hkvstore and @jfrumar Is my change still causing an uncaught exception or is it a problem of CrossWalk not supporting getTextZoom and setTextZoom methods. If it's the later, I may need to refactor the getTextZoom and setTextZoom methods to use getResources().getConfiguration().fontScale.

@hkvstore
Copy link

is it a problem of CrossWalk not supporting getTextZoom and setTextZoom methods.

I cannot say for sure, I tested on a real Android phone only, there is no error when calling setTextZoom(), but I suspect the CrossWalk plugin does not support getSettings().

@majornista
Copy link
Collaborator

Looks like getSettings() has been added in Version 6 - Crosswalk 17, however it doesn't seem to do anything to the text zoom setting within Crosswalk's Chromium instance.

@JeremyColton
Copy link

JeremyColton commented Sep 27, 2016

Hi,
I'm using Cordova 5.0,0, Android 6, CrossWalk 2.0.0, running on Samsung S4 and I get this related error when the app starts up:

09-27 23:40:10.951: E/AndroidRuntime(13802): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myup/com.myup.MobileApp500_Android}: java.lang.ClassCastException: org.crosswalk.engine.XWalkCordovaView cannot be cast to android.webkit.WebView

I don't see errors in my project in Eclipse since I use the command line to build the project via:

cordova android run

The cast complaint is on line 49 which is the 1st line below in my main java class:

WebView webview = (WebView)appView.getView(); 
WebSettings ws = webview.getSettings();
ws.setMediaPlaybackRequiresUserGesture(false);

webview.setHorizontalScrollBarEnabled(false);
webview.setVerticalScrollBarEnabled(true);
webview.setVerticalScrollbarOverlay(true);
webview.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

BigDecimal scale = new BigDecimal(width).divide(new BigDecimal(320)).multiply(new BigDecimal(100));
double globalScale = scale.setScale(3, RoundingMode.CEILING).doubleValue();
webview.getSettings().setRenderPriority( RenderPriority.HIGH );
webview.setInitialScale( (int)globalScale );

So how can I fix this (many thanks) ?

Also, since I am running Android 5.0 which has a new Chrome/53.0.2785.124 Mobile, does the browser that comes with CrossWalk offer any javascript speed advantages?

@majornista
Copy link
Collaborator

@JeremyColton I don't think that you can cast the org.crosswalk.engine.XWalkCordovaView as a android.webkit.WebView. You can see how I work around this here: https://github.com/phonegap/phonegap-mobile-accessibility/blob/master/src/android/com/phonegap/plugin/mobileaccessibility/MobileAccessibility.java#L139

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants