Bug 46500 - WebView freezes on Samsung Galaxy S6 / S7 with either Android 5.0 or 6.0
Summary: WebView freezes on Samsung Galaxy S6 / S7 with either Android 5.0 or 6.0
Status: RESOLVED DUPLICATE of bug 19745
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 7.0 (C8)
Hardware: PC Windows
: --- critical
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2016-11-04 16:59 UTC by Sid Dubey
Modified: 2016-11-18 03:57 UTC (History)
5 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
APK generated using Android Studio (6.00 MB, application/x-zip-compressed)
2016-11-10 22:25 UTC, Sid Dubey
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 19745

Description Sid Dubey 2016-11-04 16:59:57 UTC
This issue is specific to Samsung Galaxy S6 or S7 devices. The List in the attached project does not scroll and just freezes. To reproduce: 

1. Deploy the attached project in release mode on Samsung Galaxy S6. 
2. There are 999 items in the List. The List freezes as soon App is launched.
Comment 1 Sid Dubey 2016-11-04 17:04:02 UTC
The Repro project is not getting smaller than 8000 KB. I can provide the same.
Comment 2 Sid Dubey 2016-11-10 22:25:12 UTC
Created attachment 18424 [details]
APK generated using Android Studio
Comment 3 Sid Dubey 2016-11-10 22:25:49 UTC
As advised by Jonathan, we created the Native Java sample project to display same behavior as Xamarin App. This native app works just fine on S7 device and there is absolutely no problem with content display and scrolling it. Attaching the APK which was generated using Native Java.
Comment 7 Brendan Zagaeski (Xamarin Team, assistant) 2016-11-18 00:26:31 UTC
I'm not sure this bug report so far accurately captures the problematic behavior as described by the original user.  For example, the following phrase from Comment 0 does not seem to match the original description from the user:

> The List freezes as soon App is launched

As far as I can tell, the problem was never described as causing "freezing" or "hanging" by the original reporting user.  That is, I don't think they ever said that the list became completely unresponsive (aka "froze").  The behavior they described was instead that:

(a) The _performance_ of scrolling on a Samsung S6, Android 6.0 was noticeably worse than on some other devices (one particular device mentioned was a Samsung J7, Android 6.0 device).  Indeed, in my preliminary testing on an Android S6, Android 6.0 device I have seen what I would describe as jerky and low-frame-rate scrolling for the test case.  I will plan to compare that performance with a couple other devices to get a better hands-on "feel" for the problem.

and

(b) When they tried packaging roughly the same WebView (that uses Angular JS + Ionic) into a Cordova app, the performance appeared to improve markedly.  Comparing Cordova to Xamarin is more interesting than usual in this particular case because the Xamarin test case is using a WebView to render the list.  (Often Xamarin apps would not be using a WebView at all but would instead be rendering the data into a ListView.)
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2016-11-18 01:58:18 UTC
> I will plan to compare that performance with a couple other devices to get a
> better hands-on "feel" for the problem.


An old LG Optimus L9 Android 4.1.2 (with a less powerful CPU + GPU) dramatically outperforms a Moto G3 Android 6.0 device (as well as the Samsung S6, Android 6.0 device) for the C# test case.  (Note that I did have to comment out the `SetWebContentsDebuggingEnabled()` line to test on Android 4.1.2, but changing that line did not perceptibly alter performance on the Android 6.0 devices, so I'm comfortable making the comparison.)


The Moto G3 Android 6.0 device demonstrates noticeable pauses in my tests (it gets a bit closer to the description of "freezing" from Comment 0).  It sometimes won't respond to my vertical swipe gestures for several seconds at a time.




## Testing a candidate change that was reported to have a pronounced effect on the performance (from some additional conversation outside of Bugzilla)


### Changes to try

Remove the `Theme` property assignment from the `[Activity]` attribute:

Theme = "@style/Theme.Splash"


### Results

The performance / scrolling smoothness improves _dramatically_ on each of the following tested devices:

- Samsung S6, Android 6.0.1
- Moto G3, Android 6.0
- Samsung S7 Edge, Android 6.0.1




## Additional testing environment info

Xamarin.Android 7.0.2.37 (ce955cc0476f5d4821066f7a04ff5660caccaa4b)
Mono 4.6.2 (mono-4.6.0-branch/db69866)

Mac OS 10.11.6

JDK 7u79 (1.7.0_79), 64-bit

Android SDK Tools Version: 25.2.3
Android SDK Platform Tools Version: 25
Android SDK Build Tools Version: 23.0.3




## A guess at an explanation for the device-to-device variation across different Android 6.0 devices, and my planned follow-up steps

The tight dependence of this problem on "Theme.Splash" could mean that the _presence_ or _absence_ of that theme in different device manufacturers' customized versions of Android has a strong effect on the scrolling performance.  (Another similar possibility is that there could be some variation in the _implementation_ of that theme among the customized versions of Android.)

If that guess is correct, then I suspect I will be able to adjust the Java test case so that it demonstrates the same problematic behavior.  I will take a try at doing that and report back with the results.
Comment 9 Brendan Zagaeski (Xamarin Team, assistant) 2016-11-18 03:46:42 UTC
I was indeed able to replicate the same problematic behavior in the Java test case.  Along the way I found out that "Theme.Splash" is not a built-in theme, but rather a custom theme defined in `strings.xml` in the C# test case [1].  The important thing is that the custom style sets a "windowBackground" image:

<item name="android:windowBackground">@drawable/splash</item>

(`splash.png` is a bitmap image included in the `drawable` and `drawable-land-xhdpi` resource folders.)



Commenting out that single line from `strings.xml` is sufficient to stop the problem.  The performance problem is therefore related to the fact that the WebView is being scrolled _over_ a bitmap background image instead of over a blank screen.  The device-to-device variation in performance is presumably due to differences in the graphics layering or compositing approaches used on those devices.

In any case, it seems safe to say that issue is not related to the Xamarin toolchain, so I will mark the issue as RESOLVED UPSTREAM.  (I believe this is also a duplicate of Bug 24508 and a duplicate of the upstream "Large background image" behavior described in Bug 19745, Comment 11.)




## Devices tested

Each of the following devices showed the "bad" behavior in the Java app when "windowBackground" was defined, and the "good" behavior when "windowBackground" was _not_ defined:

- Samsung S6, Android 6.0.1
- Moto G3, Android 6.0
- Samsung S7 Edge, Android 6.0.1



As with the C# test case, the LG Optimus L9, Android 4.1.2 device showed relatively "good" behavior even when "windowBackground" _was_ defined.




## Footnotes

[1] Storing custom styles in a file named `styles.xml` is perhaps more conventional than using `strings.xml`, but the name of the file doesn't matter for our purposes here.
Comment 10 Brendan Zagaeski (Xamarin Team, assistant) 2016-11-18 03:57:20 UTC

*** This bug has been marked as a duplicate of bug 19745 ***