I'm currently using WebView.draw() to take a screenshot of the entire WebView and save it into a Bitmap (based off of this solution). It has worked perfectly up until now.
I was recently testing this functionality on a Nexus 5 (please note that on the Nexus 5 the WebView in question is bigger than the screen, so the user can scroll both horizontally and vertically) running Lollipop 5.1 and the latest update of Android System WebView (version 42.0.2311.137 at time of writing) when I noticed that the generated bitmap was wrong. It had the correct dimensions but instead of showing the whole WebView, it only had the part of the WebView that was visible to the user when the method was called.
I have tried uninstalling all updates to the Android System WebView (thus bringing it back to version 39 (1743759-arm) and with the factory version the functionality works fine. So this problem is due to a relatively recent update of the Android System WebView. I wasn't able to find a change log so I can't figure out what has changed and how to fix it.
Below is a quick visual explanation:
Has anyone else encountered this problem and found a possible solution ?
You need to call WebView.enableSlowWholeDocumentDraw() before creating any WebViews. That is, if you have any WebViews in your layout, make sure you call this method before calling setContentView() in your onCreate().
Related
I am facing an issue in WebView in devices running API 27 (8.1.0).
I pass off my params in the userAgentString based on which a php page loads the appropriate data. When I open the WebView for the first time it works well.
However, whenever I open the WebView after this first time (I call setUserAgentString each time I load it, with fresh values), it persists with that old value of userAgentString, thus not loading the correct data. This happens irrespective of whether I am in the same activity and re-using the same WebView, or move to a different activity where a new instance of WebView is used.
The following devices gave this odd behaviour -
Google Pixel 2XL, version 8.1.0
Xiaomi Mi A1, version 8.1.0
...and the webview was working perfectly on the following devices, not showing this behaviour -
Samsumg GALAXY Tab SM-T825, version 8.0.0
Moto G4, version 7.0.0
HTC Desire 526, version 4.4.2
I think this could be linked with how the Android Webview implementation has been changed to Chrome in Oreo.
However, the behaviour did not change irrespective of what I set as "Webview Implementation" in Developer settings, implying that may not be the cause.
Additionally, only when I clear data, or do a fresh install, is the userAgentString value reset.
I have read dozens of posts on SO, and tried all sorts of methods related to WebView and WebSettings, but I haven't managed to find a solution.
What am I missing here?
Maybe, this code can help you.
webView.clearCache(true);
webView.clearHistory();
webView.getSettings().setAppCacheEnabled(false);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
Lucky :)
I experienced this issue recently and the problem was that the device had an outdated Chrome WebView framework. Simply update it via the Play Store and the issue should resolve.
I have 2 weird behaviors, and I think they might be related, but I am not sure..
1) In my phonegap app (Remini), local offline images (icons) sometimes (not always) are not loaded/displayed on Android 4.4.2. For example Look at the difference between the two screen shots:
2) The second problem (in the same Android 4.4.2), is that I when the user picks an image from his gallery (using a non-standard image picker plugin for phonegap), sometimes, the image simply doesn't load. The image paths / URIs are returned to the javascript correctly, and when I am trying to assign these to an .src, the onload event doesn't fire.. In other (lower) versions of Android it worked just fine. Now in order to prevent some anticipated comments - My img.onload event is defined before the img.src assignment, and the plugin works correctly on other versions..
Now, I am not sure the problems are related, but in both cases, there is an unloaded image element, although with different sources..
Does anybody know one of these problems? Are these related?
I have built hybrid app with Sencha touch 2.3 and till recent it was working fine but i recently updated the Android System Webview via Play Store (i have moto g running android 5.0.1) and now i am encountering various bugs in UI as follows :
The selectfield picker does not work correctly now. It behaves randomly. The store bound to it has data but no items are displayed in the picker when it opens. At times items do get displayed but you cannot select the items at bottom because picker always resets the selection to the item at top.
Few screens show up blank initially when rendered for the first time. As soon as user touches the screen and moves a little bit the whole screen/view becomes visible.
Also there might be other things that might have broken after updating the webview which i might not have discovered but this a big issue as far as developing for android is concerned with sencha touch. The webview updates are now pushed Over the Air and hence many things may break in future.
I also confirmed the above bugs in older versions of android wherein the webview has not been updated and the above bugs do not show up in.
I am thinking of using crosswalk as the solution to the issues with the webview. Anyone with the same issues or any tips regarding a fix ?
I ran into a similar issue with my Sencha Touch app (almost nothing rendered). Here is the workaround I used which seems to work great:
http://trevorbrindle.com/chrome-43-broke-sencha/
Thanks #Ian. The link was tremendously helpful and it solved the issue for now. Sencha has not officially released a build with these fixes so the overrides are the only solution right now.
For anyone facing same issues here is one more link from the Sencha Forums where all the issues sencha frameworks are facing with Chrome 43 are stated and solved.
https://www.sencha.com/forum/announcement.php?f=92&a=58
I am also stuck with same issue and i found solution we should not update the chrome. Better download 42.0.2311.152_chrome64_installer which is offline exe for chrome.
This bug only occurs on my Nexus 5 and my Nexus 7 running Lollipop.
EDIT
This bug also occurs in the new Inbox app by Google, when I'm going into Inbox > Settings > Notifications > any item and go back...
/EDIT
compileSdkVersion 21
buildToolsVersion 21.1.1
compile 'com.android.support:appcompat-v7:21.0.2'
I'm having a GalleryActivity that shows multiple images, once per page (inside a ViewPager. When I hit the back button, sometimes the Android's SystemUI have glitches.
Normal view
Glitched view
See how the views repeats themselves, and inside the system itself?
A simple touch event brings back the normal SystemUI views.
What is going on?
Might be similar to:
Android 5 screen glitch/static with Google Maps Fragment inside a Viewpager
Android Lollipop Activity Screen corrupted
Setting android:hardwareAccelerated="false" is a kind of extreme solution, as graphical performance is likely to be very bad.
If you can pinpoint the view that is misbehaving and causing this issue, a better fix would be to switch it to software rendering instead, via setLayerType(), e.g.
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
Funny thing is, I haven't experienced any rendering glitches with Lollipop so far, but we did see them in KITKAT (as mentioned in this question), and only when WebViews are present on the screen.
I would recommend experimenting with toggling this on different views until the problem is isolated (especially if it's easy to reproduce).
So far, every occurence of this issue has been related to WebViews (or components that use WebView, such as AdMob). According to the AOSP Issue Tracker the problem is fixed in Android 5.0, but it doesn't seem to be the case.
I've seen UI glitches with Lollipop, though different than yours. The only workaround I found was disabling hardware acceleration:
android:hardwareAccelerated="false"
at the Activity or Application level. If this resolves your glitches, make sure to report this to Google as this would indicate a bug in the platform. There is already at least one open report with them already.
I certainly wouldn't want to deploy an application with this setting, it's really only intended to answer the WHY and help prove that it's not a bug in your code.
Hope this helps!
EDIT 12/10/2014:
#matiash offered a much more precise answer than this "sledgehammer" suggestion. I was seeing drawing glitches mostly on the ActionBar in a multi-tab app with ViewPager, and always on tabs/pages without any WebView at all. However, one of my tabs/fragments does have an embedded WebView, and when setting it to software rendering, my glitches appear to have gone away. I'm not at all uncomfortable putting the workaround suggested by #matiash in a shipping app...though it still points to some underlying issue in the platform.
I have also witnessed this problem in my own app.
Any Android devs ever experience this kind of visual static? (see picture)
Not only did I get that kind of visual static, but also repeated drawing. Only witnessed it on Nexus 5 with 5.0 when developing with api 21 and support library 21.0.+.
For me its not very reproducible. It will happen repeatedly during one session of use, but the next day I won't be able to reproduce it.
I am not using any WebViews (accept maybe via admob). I am using ViewPagers with fragments. I am also using DragSortList and first started seeing the issue in Activities that used it.
https://github.com/bauerca/drag-sort-listview
How reproducible is it for you guys?
have you tried to set android:fitsSystemWindows="true" in your Fragment layout? this will make sure the layout is below the statusBar, im not really sure about the navigation buttons but i guess this should work for it too.
Call request layout on DecorView after rendering:
getActivity().getWindow().getDecorView().requestLayout();
I call it using postDelay() in WebViewClient.onPageFinished(). It's not a perfect solution (just a workaround) but maybe better way like LAYER_TYPE_SOFTWARE.
.........go to settings and then developer options(if they are not visible... go to about phone then click on build number 7-10 times and developer mode will be on) and there scroll down and untick 'show layout bounds' and you are done. its simple and easy.
I have an web application, On form submission i wish to show loading image until the next page loads,the issue is with Jelly Bean, it Simply freezes the page 1, after some time it loads the page 2, loader is not at all showing
I tried blockui.js, show/hide div on form submission but no Expected result.
I don't find this issue in other android versions like Gingerbread and ICS.
Note: When i delay my form submission, it shows the loader image.
I think in jelly bean There is a change in web-kit. JB uses the web-kit of chrome. That's why the app runs smoothly on all other versions and it becomes weird when it comes to Jellybean. you need to manage it it any other ways. I also faced somewhat a similar problem when I had done an application compleatly based on html and js. Still i was not able to complete this problem and i need to drop the app due to kind of reasons