When webView load bad javascript,the memory grow rapidly on some webview version
Reported by
yangzhen...@gmail.com,
Mar 8 2018
|
|||||||
Issue description
When i load 3 webview with sample javascript at the same time,
code like this(may be load other third party bad js):
<script>
for(var i=0;i<100000;i++) {
console.log("Hello, World!");
}
</script>
for (int i = 0; i < 3; i++) {
WebView webView = new WebView(this);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDisplayZoomControls(false);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setDomStorageEnabled(true);
webSettings.setSupportMultipleWindows(true);
webView.loadUrl("file:///android_asset/js.html");
}
Mobile:galaxy s6 edge
model:SM-G925F
system: 7.0
Android System WebView: versionCode: 288309150 versiontName: 55.0.2883.91
When i run this sample,i found it cost about 1G memory rapidly
see image file:2018-03-07 at 7.30.43 PM_SM-G925F.png
Mobile:Nexus 6
model:MOB31E
system: 6.0.1
Android System WebView: versionCode: 332514450 versiontName: 65.0.3325.144
When i run this sample,i found it cost about 1G memory rapidly
see image file: Screen Shot 2018-03-07 at 7.36.33 PM_nexus6.png
but change Android System WebView to : versionCode: 246011700 versiontName: 44.0.2403.117
it only cost about 10M
see image file: Screen Shot 2018-03-07 at 7.39.14 PM_nexus6.png
So,i test the Android System WebView from 44 to 65,i draw below conclusion.
1. Between webview version 44 and 52,on nexus 6 system 6.0.1,memory cost is normal.
2. Between webview version 53 and 57 on nexus 6 system 6.0.1,memory cost is high,but grow slowly.
3. Between webview version 55 and 57 on galaxy edge system 7.0,memory cost is high and grow very quickly.
4. On webview version 58 on nexus 6 system 6.0.1,memory cost is normal.
5. Between webview version 59 and 65 on nexus 6 system 6.0.1,memory cost is high and grow very very very fast
6. When i test on system 8.0,use webview version 62 and 65 with mobile sony and huawei,memory cost is normal
And we also collect some related crash log
e.g.: /data/app/com.android.chrome-1/base.apk
we used tecent bugly issue tracker to get more useful crash log
https://bugly.qq.com
Mobile model: Moto E (4) Plus
System: Android 7.1.1,level 25
CPU: armeabi-v7a
see file:
moto_google-breakpad_crash_log.txt
moto_wrong_stack.txt
Mobile model: XT1635-01
System: Android 7.1.1,level 25
ROM:motorola/addison_verizon
CPU: armeabi-v7a
see file:
XT1635-01_wrong_stack.txt
XT1635-01_breakpad_crash_log.txt
Expected result:
When webview load bad javascript,the memory grow slowly and will release it later,
the memory will not grow too much in few seconds like chrome webview 44 or 58
Actual result:
When webview load bad java script, the memory grow very fast between 59 and 64 and grow fast between 53 and 57
,
Mar 9 2018
,
Mar 12 2018
Hi Guys! We suspect that webview native memory grow fast with some malicious or bad js. When webview load some malicious or bad js, the memory grow so fast and high. When the memory grow high enough, the system of Android mobile will be kill the app immediately. And We received SIGABRT or signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) crash logs on crash tracker console. So, Our solution is decrease the count of the webview in one app and control the count of webview which execute to load js at the same time. After we did it, the crash(signal 5 (SIGTRAP), code 1 (TRAP_BRKPT)) grow slower than before. And the rate of crash is getting normal at present. But this solution is not the best way for my app, the crash of rate will be grow in a future maybe. So i hope team of android system webview to check it as soon as possible. If it were true, i hope fix it in next android system webview version. It's import for our app and other's app which use amounts of webview. Thanks!
,
Mar 12 2018
We have received a massive spike in these native Chrome crashes since March 7th here at Pandora. Since then, we are seeing up to a 5x increase to our daily overall crashes rate due to this issue. This crash kills our process before our internal bug reporting software can log an event, so we only have limited data from Google Play Console, but it all seems to match the symptoms listed in this ticket (although we are seeing similar lesser crashes occur at the same time on non-7.x Android versions). Vetting all javascript coming into our app through ads is extremely difficult, so this issue must be handled inside the WebView itself. A fast patch to the WebView or workaround would be greatly appreciated.
,
Mar 12 2018
I am very glad to see that others provide the same important information. Thanks for the friend from pandora. We test it with Nexus 6 System 6.0.1, but the log of crash won't be collected by google play consle and also happen on 5.X. The google play console may be only collect little crash from system under 7.X. Decrease the count of ads loading at the same time and control the count of ads, the crash will grow not so fast. More and more people update system webview from google play with time goes by.
,
Mar 12 2018
cc'ing people who might be more familiar with memory.
,
Mar 12 2018
does this reproduce?
,
Mar 13 2018
After looking more into this, we came to exactly the same results as `yangzhen...` NOTE: Many Samsung devices such as Samsung Galaxy Note 4 (SM-N910A, API23) won't even classify WebView consumed memory properly as `native heap` and will report it as `unknown`. Therefore, memory spikes will not be visible in Android Memory Profiler, but could be observed using `dumpsys meminfo`.
,
Mar 15 2018
assigning to ctzsm@ first mariakhomenko@ & dskiba@, is this a known issue?
,
Mar 15 2018
Not something I am aware of. +hpayer@ on the assumption this may be v8 since it depends on a specific script to execute.
,
Mar 21 2018
As for the crash stack traces, could you please re-attach crash logs with the entire MICRODUMP attached? i.e. everything from the line including BEGIN BREAKPAD MICRODUMP to END BREAKPAD MICRODUMP (including those two lines).
,
Mar 21 2018
Note that this (native heap being eaten up in the app process using WebView) reproduces for me on ToT WebView, using a Nexus 5, running L. It does seem to be flaky though (the memory doesn't always grow like crazy).
,
Mar 21 2018
can you take a memory-infra trace and see where that memory is going? https://chromium.googlesource.com/chromium/src/+/lkcr/docs/memory-infra/
,
Mar 21 2018
,
Mar 21 2018
Internally we can see a big spike in V8 OOMs that peaked on March 9th, which appears to have resolved by March 13th. That might indicate a change in the JS being executed. Does the pandora app use JS for anything other than Ads?
,
Mar 21 2018
The stack-traces don't show anything consistent in the allocations happening during these OOMs (i.e., the allocations are coming from multiple places in V8 - allocating maps, bytecode arrays, code, arrays, etc.), so I don't see anything in the that indicate a specific leak / allocation bug in any area of V8.
,
Mar 21 2018
@tobiasjs@chromium.org we don't restrict JS usage for Ads purposes only, but based on our internal analytics for OOM crashes, we have a high confidence that bad JS comes to us externally through ads.
,
Mar 22 2018
gsennton@chromium.org Mobile:HUAWEI-TLOOH System: 5.0 ROM:EMUI 3.1 chrome version:64.0.3282.137 I test the case that webview haven't been added to the activity, the js will not execute and the memory is normal. But i test the case that webview is added to the activity, the js will execute, the memory of mobile grow slowly and will be high in few minutes. On system 5.0, the performance of webview's memory is better than 6.0 and 7.0. see the image file: huawei_memory.png After load 3 webview with bad js, the memory is not so high. android code: FrameLayout layout = new FrameLayout(this); setContentView(layout); for (int i = 0; i < 3; i++) { WebView webView = new WebView(this); layout.addView(webView); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDisplayZoomControls(false); webSettings.setLoadsImagesAutomatically(true); webSettings.setBuiltInZoomControls(true); webSettings.setDomStorageEnabled(true); webSettings.setSupportMultipleWindows(true); webView.loadUrl("file:///android_asset/js.html"); } You could try this case on android mobile 6.0 or 7.0. I hope this can help you!
,
Mar 22 2018
The example you have provided (logging to the console 100k times) seems like a case in which javascript might just take up a lot of memory (for whatever reason) - and I don't really see why you would be executing javascript like that (or why we would try to support a use-case like that). If an ad is serving javascript like that then that ad should probably be restricted / removed. Is that something we/you can do?
,
Mar 22 2018
#17. Looking at crash timeseries, there are other that replicate that seem like they are probably ad-related, however the 4 day spike that Pandora observed was not seen by any other app. That would tend to argue against that specific event being ad-related. The median uptime was depressed during that time, but there was no indication that I can see that this was a startup crash. We don't have any data that can provide any deeper insight. Maybe your analytics can?
,
Mar 22 2018
gsennton@chromium.org The issue is the actual discrepancy in how different versions of WebView handle this sample javascript. Versions 44 and 52 don't require much memory to process logging to console 100k times. Version 64 will take about 1GB of memory. Something has obviously changed in how heavy JS code is being internally processed. This means that ad creatives that were perfectly fine on version 52 will now result in OOM crashes.
,
Jun 1 2018
I have been experiencing the same issue for my app in the past couple of months. My crash rate is now around 8% because of this with above a million of monthly crash: signal 5 (SIGTRAP), code 1 (TRAP_BRKPT) This issue has been reported month ago. Many developers are facing the same issue because of the admob banner they are using. Please take this issue seriously and fix it. I already submitted many micro dump to the admob team
,
Dec 14
I am here (and have starred this issue) because it's the only search hit on the issue tracker for "signal 5 (SIGTRAP), code 1 (TRAP_BRKPT)". I have a hybrid app (AnkiDroid - it's open source and visible on github if that matters) that uses a WebView to load flashcards and can load arbitrary JS from users. I'm not sure what JS is being loaded by the users but this is my top crash now, by far, with a significant uptick since the current chrome (70.0.3538.110 for me) started rolling out on Android. Most visible on Android 8.0/8.1, with some on 7, no reports prior. Let me know if you need more information (and ideally, how to get it...)
,
Dec 14
TRAP_BRKPT just means "a fatal error/assertion was hit" and covers tens of thousands of different possible causes, so it's far from guaranteed that your issue is related to this one. I'm guessing you're seeing this in the Play Store developer console? File a new WebView bug here with all of the crash information that you can see there (the entire output with the stack/registers/etc) for a start - if any of your users who are experiencing the crash are able to grab the "adb logcat" output when the crash happens, then attaching that would be extremely helpful. Also, please include the exact, full package name of your application as it's published on the Play Store (or just the full URL to the app on the Play Store) so we can look up your app in our crash database to see what's being reported via the webview crash system, as well as repeating all the information you posted here. If you can reproduce the issue yourself, then telling us how to do that would be the most useful thing, but I'm guessing you can't from your description. In general, please always just file a new bug about issues you're having rather than replying to an existing issue, even if it looks similar to you (though feel free to mention the bug number you think it might be related to - that's helpful information). Our crashes are, unfortunately, not always easy to understand without experience in the chromium codebase, and we don't always notice replies to old bugs as the people involved in the bug may not be paying close attention. We have a dedicated bug triage rotation for newly filed bugs and someone will look at them pretty quickly in most cases.
,
Dec 19
Thanks @torne - sorry to clutter this issue then, and thank you for the detailed guidance |
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by yangzhen...@gmail.com
, Mar 8 2018199 KB
199 KB View Download
83.1 KB
83.1 KB View Download