20

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

normal

Glitched view

glitched

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:

matiash
  • 54,791
  • 16
  • 125
  • 154
shkschneider
  • 17,833
  • 13
  • 59
  • 112
  • Just for reference sake, this is the issue in Google's Android issue tracker: https://code.google.com/p/android/issues/detail?id=81832&q=systemui%20transparent&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars – Hakkar Apr 02 '15 at 15:06

6 Answers6

17

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.

Community
  • 1
  • 1
matiash
  • 54,791
  • 16
  • 125
  • 154
  • @shkschneider Yes, I'd hope too. But seeing as this was broken a while ago and there has been no feedback, I wouldn't hold my breath. We've been going with this ugly workaround for a while now. :( – matiash Dec 10 '14 at 20:53
  • 1
    Its the problem with the way Android L handles web view data rendering. webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); solves the problem. – Surendra Kumar Dec 19 '14 at 13:55
  • 1
    Ran into this problem as well with a WebView shown within a ViewPager. It was 100% repeatable by paging between WebViews and then navigating away from the activity. Strangely the display corruption never occurs on the WebView itself -- it happens on a completely separate activity: it would show up when returning to the launcher activity, two steps back in the navigation list. I haven't been able to replicate the issue since turning off hardware acceleration for the WebView using setLayerType. – Lorne Laliberte Mar 09 '15 at 18:06
  • @matiash-Hi, I tried both but not working for me. My layout is going below "statusbar" and "navigationbar". whn I update my Textview dynamically thn screen automatically got right but I need to keep screen proper before dynamic updation also... – Ajit Sharma Aug 10 '16 at 05:27
2

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.

CSmith
  • 13,318
  • 3
  • 39
  • 42
  • So you're thinking, like me, that this is a platform/framework bug? – shkschneider Dec 05 '14 at 15:54
  • I have reproducible glitches very similar to the "Google Maps Fragment inside a ViewPager" link you've shown. Disabling hardware acceleration fixed it. I've reported to Google, still awaiting feedback. Not sure if your problem is the same, but its easy enough to try... – CSmith Dec 05 '14 at 15:56
  • Disabling hardware acceleration (as extreme as this is for a "fix") seems to prevent that issue but also makes every lollipop animations (like ripples) very slow and so a bit ugly... – shkschneider Dec 05 '14 at 15:56
  • Hope to see a fix from Google soon! Glad to have helped – CSmith Dec 05 '14 at 15:59
  • I know this does solve my issue by decreasing my application efficiency, but it's the only working thing I found out there. Hope to see a fix from Google too. Thank you – shkschneider Dec 05 '14 at 16:03
1

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?

Community
  • 1
  • 1
Shep Shapard
  • 148
  • 8
0

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.

Kosh
  • 6,140
  • 3
  • 36
  • 67
  • that's freaking weird. how it happens exactly ? is there any scenario that it happens on it? – Kosh Dec 05 '14 at 15:31
  • It happens most of the times when I'm viewing a large image. But as said in my question, I reproduced the same error (SystemUI getting transparent) on the new Inbox app by Google... – shkschneider Dec 05 '14 at 15:33
0

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.

RamenChef
  • 5,557
  • 11
  • 31
  • 43
-1

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

  • The question's referring to the graphics getting displayed in the system UI areas (system buttons and system bar), not the layout bounds. – akiraspeirs Feb 20 '16 at 12:34