Android webview can't draw canvas after chrome updated to 76+ - android

My webview has drawing functionality inside a canvas which was working fine. But after upgradation of Chrome it stopped drawing inside canvas. I have a work around, by setting hardware acceleration true it works perfectly, but issue is my app's memory consumption increased rapidly. Is there any solution of this problem?
I am using Cordova for cross platform.

Well, I don't know about Cordova, but I think this can also help you. I found that the key to solving the HTML5 canvas issue in Android webview is within AndroidManifest.xml. What did I have to do? I kept the strategy of using a hybrid (custom) webview, because as I develop in Xamarin Forms for both iOS and Android, I needed the same solution on both platforms. On Android I did:
// Java (or similar [laughs])
// Enable hardware acceleration using code (>= level 19)
if (Build.VERSION.SDK_INT >= 19) {
yourWebviewObj.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else {
yourWebviewObj.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
yourSettingsObj.setRenderPriority(WebSettings.RenderPriority.HIGH);
yourSettingsObj.setCacheMode(WebSettings.LOAD_NO_CACHE);
// Xamarin for Android
// Enable hardware acceleration using code (>= level 19)
if (Build.VERSION.SdkInt >= 19)
{
yourWebviewObj.SetLayerType (LayerType.Hardware, null);
}
else
{
yourWebviewObj.SetLayerType (LayerType.Software, null);
}
yourWebviewObj.Settings.SetRenderPriority(WebSettings.RenderPriority.High);
yourWebviewObj.Settings.CacheMode = CacheModes.NoCache;
And finally, within AndroidManifest.xml find for android:handwareAccelerated="false" and you can change the value from false to true. This tip (additionally) works for both the Java universe and Xamarin.
Had another person with the same problem at Android WebView with layer_type_software not showing HTML5 canvas content where I also posted the same solution. Sorry if my help was not enough, but today I develop applications using Xamarin. Anyway I believe that following this path will help you.

Related

Getting "no method with name='setBackground'" upon changing .Background property on legacy Android versions (<4.1)

Getting,
no method with name='setBackground' signature
or
no method with name='setBackground'
upon changing .Background property (to change the background visuals) in the app running on legacy Android versions (<4.1)
Any ideas on how to fix this?
As this question about Eclipse suggests, setBackground is problematic on API below level 16. Unlike covered in the question though, to work around the issue AND have your code Android 4.0-compatible, you'd want to change your background with the following (reproducible logic)
if (Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.JellyBean)
{
layout.SetBackgroundDrawable(gd);
}
else
{
layout.Background = gd;
}

Crosswalk (xwalk) pull to refresh not working

I'm using Crosswalk (XwalkView) instead of the default Webview on Android but it seems that the defalt pull-to-refresh functionality doesn't work on Android 4.3. I've tested it on 5.0 and it's ok, but on 4.3 and 4.2.2 it doesn't work. I'm guessing it has to do with < 5.0 ?!
I've tried something like this to enable it, but it failed to work:
//Disable the edge effect and try to enable pull to refresh in case we're using xwalk webviews
if (BuildConfig.IS_XWALK) {
final String INIT_SWITCHES[] = {"Xwalk", "--enable-pull-to-refresh-effect", "--disable-overscroll-edge-effect"};
if (!CommandLine.isInitialized()) {
CommandLine.init(INIT_SWITCHES);
}
}
Any ideas ?
Actually, we already have a JIRA about this feature, please track it here: https://crosswalk-project.org/jira/browse/XWALK-6277.
It has some block issue before, but we will continue investigating how to implement it.

flash air for android touch event DOESN`T WORK

I was trying to make something in Adobe Flash, Air for android. I simply made a square and converted it to an Symbol (called 'hello') and I entered this code.
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
hello.addEventListener(TouchEvent.TOUCH_TAP, tap);
function tap(event:TouchEvent):void
{
hello.x+=15;
}
but nothing happend. I even used CODE SNIPPERS, and also tested this on my phone(ALCATEL onetouch idol mini), and it also said that there are no errors.What have I done wrong?
You set everything correctly but forget only one important thing: check if the system supports touchevent.
if(Multitouch.supportsTouchEvent)

Android WebView__Use HTML5 video tag conflict with transparent background?

I am trying to make a Browser on Android and it extends WebView class.
There are two functions of my Browser:
1.Could play html5 video tag.
(I enable HardwareAccelerate and setWebChromeClient and it works fine on Android 4.0.)
2.The Browser must have a transparent Background.
(On Android 4.0, just setBackground(0) is not enough. I must also use setLayerType(LAYER_TYPE_SOFTWARE, null).)
But when I use setLayerType(LAYER_TYPE_SOFTWARE, null), the video tag can not paly. And that means setLayerType(LAYER_TYPE_SOFTWARE, null) disable HardwareAccerlarate so the video tag can not work.
So Can I consider that On Android 4.0, the two function is conflicting?Is there any workaround?
//set BackGroundColor
setBackgroundColor(Color.argb(0, 0, 0, 0));
if(android.os.Build.VERSION.SDK_INT>=11){
setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
}
//set WebChromeClient
setWebChromeClient(new WebChromeClient());
I have to say that, seems no guys met this issue as me.
So I think the two functions mentioned in my question is really conflicting.

Android:cannot make a selection after WebView search with highlight

Hello I have a bug in my app and I cannot figure it out.
I want to search for text in my WebView and get the found Text highlighted
for Android 1.5-2.3 this works quite well
public void onClick(View v){
webView1.findNext(true);
int i = webView1.findAll(findBox.getText().toString());
try{
Method m = WebView.class.getMethod("setFindIsUp", Boolean.TYPE);
m.invoke(webView1, true);
}catch(Exception ignored){}
}
}
for Android 3.0+ I have to use the JavaScript workaround from here, because Google doesn't support the highlighting of searched text for incomprehensible reasons
And now my Bug: After the search on my WebView I get the highlighted Text, and I can't select the Text anymore. The only fix I could use is the JavaScript workaround in older Android versions, too. But the function runs very slow and it takes about 10 seconds until the text gets highlighted. I Hope someone has a better solution/fix :)
Thank you
I use the same for 3.x then it did not work on 4.0.x.
Yesterday I updated to 4.0.4 and now highlight works again.
So the solution can be found in the 4.0.4 sources.
OK I have found a quite good solution.
Here is a JavaScript code for Highlighting, that runs really fast :) http://4umi.com/web/javascript/hilite.php#thescript
Anyway I don't understand, why I can't selecting text after the of the official Webview search
For Android 3.x I used webview.showFindDialog(stringtofind, true);
use findAllAsync() instead , finAll() is deprecated in API 16;

Categories

Resources