Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Works around a crashing browser bug affecting Android browser 2.3.x on some devices #1019

Closed
wants to merge 1 commit into from

Conversation

lukemelia
Copy link

This pull request works around a crashing browser bug affecting Android browser 2.3.x on some devices. The bug was triggered by code in animate that was introduce since 1.7.2.

A bug against jQuery was filed here a couple of months ago: http://bugs.jquery.com/ticket/12497. The bug thread references a number of devices that exhibit this crash.

A simple example (without jQuery) of JS that will trigger this crashing browser bug is here: http://jsfiddle.net/wCQvh/

The workaround in this commit attempts to preserve the same logic as the previous code but avoids triggering the browser bug.

…id 2.3.5. The bug was triggered by code in effects. Fixes #12497.

A simple example (without jQuery) of JS that will trigger this crashing browser bug is here: http://jsfiddle.net/wCQvh/

This browser bug appears to have been resolved in Android 2.3.5. Unfortunately, there are a large number of active devices that cannot and/or will not be upgraded.

The workaround in this commit preserves the same logic as the previous code but avoids triggering the browser bug.
@@ -81,7 +81,7 @@ function Animation( elem, properties, options ) {
tick = function() {
var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
percent = 1 - ( remaining / animation.duration || 0 ),
percent = animation.duration ? (1 - (remaining / animation.duration)) : 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two points:

  • The existing logic ensured a numeric percent in all cases, but this change makes it possible to get NaN. I don't think we care, but it's worth pointing out that there is in fact a functional change.
  • I was unable to reproduce your problem with the emulated sub-2.3.5 clients available on BrowserStack... could you be more specific about the error you encounter? Could it be fixed just by wrapping the division in parentheses instead of introducing a ternary expression?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error is a segfault. The following is output from the LG Esteem that exhibits the behavior: https://gist.github.com/33772b893b28f543484b I assume the behavior is similar for the other devices mentioned in the bug thread, but I don't have those particular devices on hand to test.

I also hoped that wrapping the division in parens would avoid the bug, but the crashing behavior persisted.

When I tried removing the || 0 without other changes, there was a test failure ("Animations with 0 duration don't ease (#12273)"). With my proposed fix, the test remained green.

If an alternative fix would be preferable, I'd be happy to test it on this device.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that this is a device specific issue... Can anyone confirm 2.3.4 on another device?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a number of people have already confirmed the crashing behavior with animate on several devices and versions of 2.3.x in the bug thread: http://bugs.jquery.com/ticket/12497

@gnarf
Copy link
Member

gnarf commented Nov 6, 2012

I'm not even sure what exactly we are fixing... What is causing this crash? division? the opti? - I tested this on my Android 2.1-update1 phone and none of the fiddles fail for me...

@lukemelia
Copy link
Author

@gnarf37 I can't say for sure what is causing the segfault. This fiddle (http://jsfiddle.net/wCQvh/) was the simplest case I could get to trigger the crash.

@lukemelia
Copy link
Author

FYI, updated the title and description of the PR to more accurately reflect the affected population.

@krisselden
Copy link

The above and the previous version leave remaining == NaN if animation.duration is undefined, which is then passed to notifyWith.

If the intention is to support undefined duration, the following would be significantly more readable:

if (animation.duration > 0) {
  remaining = Math.max( 0, animation.startTime + animation.duration - currentTime );
  percent = 1 - (remaining / animation.duration);
} else {
  remaining = 0;
  percent = 1;
}

@lukemelia
Copy link
Author

My colleague succeeded in simplifying the crash-triggering fiddle even further: http://jsfiddle.net/wCQvh/24/

@dmethvin
Copy link
Member

dmethvin commented Nov 6, 2012

Worked for me on a Nexus One (Android 2.3.4), this is getting stranger by the minute. I changed to an alert just to be sure. http://jsfiddle.net/wCQvh/30/ @lukemelia is this a stock phone with a standard carrier software release?

@lukemelia
Copy link
Author

@dmethvin Yes, stock phone. Model No: LG-MS910, Android version: 2.3.4

Pretty bizarre.

@gnarf
Copy link
Member

gnarf commented Nov 8, 2012

@lukemelia does dave's fiddle crash for you too? this seems insane

Like which of these crashes:

http://jsfiddle.net/Rms2H/
http://jsfiddle.net/Rms2H/1/
http://jsfiddle.net/Rms2H/2/
http://jsfiddle.net/Rms2H/3/

@gnarf
Copy link
Member

gnarf commented Nov 8, 2012

Add http://jsfiddle.net/Rms2H/4/ to the list too please

@curiousdannii
Copy link

I have a stock LG-P690F running 2.3.4.

dmethvin's crashes, but none of yours do gnarf37.

@gnarf
Copy link
Member

gnarf commented Nov 8, 2012

@curiousdannii
Copy link

Yes that crashes.

@gnarf
Copy link
Member

gnarf commented Nov 8, 2012

Sorry to keep pushing more into the "LG Test Queue" but thanks for running these

http://jsfiddle.net/Rms2H/6/
http://jsfiddle.net/Rms2H/7/

Just want to confirm what is actually causing the issue

@curiousdannii
Copy link

No worries, I'm happy to help and I'm intrigued by this bug.

Those both work.

@curiousdannii
Copy link

http://jsfiddle.net/aMvm6/1/ works too, so you don't need two variables.

@gnarf
Copy link
Member

gnarf commented Nov 8, 2012

Next up - against actual jQuery edge, jQuery with the remainingP assignment, and minified of the same

http://jsfiddle.net/nePkZ/1/
-- skip #2 --
http://jsfiddle.net/nePkZ/3/
http://jsfiddle.net/nePkZ/4/

@curiousdannii
Copy link

1 crashes, 3 & 4 seem to work

@gnarf gnarf closed this in 8773067 Nov 8, 2012
gnarf added a commit that referenced this pull request Nov 8, 2012
@dmethvin
Copy link
Member

dmethvin commented Nov 8, 2012

@gnarf
Copy link
Member

gnarf commented Nov 8, 2012

😺 @dmethvin

@manocao
Copy link

manocao commented Sep 20, 2013

hi, i got android phone 2.3.5 (k-touch w655), without java

with phone connected by 3g or wifi, everytime i start stock browser it crashes (unexpectably, force close)

with phone rebooted and NOT connected by 3g or wifi, everytime i try to access stock browser settings it crashes (unexpectably, force close)

if then i connect by 3g or wifi, it crashes inmediately (unexpectably, force close)

i tried reinstalling same/other version browser.apk or uninstall it (not possible), editing com.android.browser_preferences.xml, deleting browser and dalvik cache, set miren browser as default (i can not establish other browser as default, not possible delete/change associations)... without success. links to internet try to open stock browser which is default but then crash

where is the error? thanks 4 all. i get this system_app_crash@ log file:

Process: com.android.browser
Flags: 0x9be45
Package: com.android.browser v10 (2.3.5)
Build: qcom/msm7627a_v7_w655/msm7627a_v7_w655:2.3.5/GRJ90/eng.root.20130119.161748:eng/test-keys

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.browser/com.android.browser.BrowserPreferencesPage}: android.view.InflateException: Binary XML file line #210: Error inflating class java.lang.reflect.Constructor
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:633)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #210: Error inflating class java.lang.reflect.Constructor
at android.preference.GenericInflater.createItem(GenericInflater.java:397)
at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:430)
at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
at android.preference.GenericInflater.rInflate(GenericInflater.java:493)
at android.preference.GenericInflater.inflate(GenericInflater.java:326)
at android.preference.GenericInflater.inflate(GenericInflater.java:263)
at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:251)
at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:262)
at com.android.browser.BrowserPreferencesPage.onCreate(BrowserPreferencesPage.java:47)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
at android.preference.GenericInflater.createItem(GenericInflater.java:383)
... 21 more
Caused by: android.content.res.Resources$NotFoundException: String array resource ID #0x0
at android.content.res.Resources.getStringArray(Resources.java:385)
at com.android.browser.search.SearchEngineInfo.(SearchEngineInfo.java:64)
at com.android.browser.search.SearchEngines.getSearchEngineInfos(SearchEngines.java:46)
at com.android.browser.search.SearchEnginePreference.(SearchEnginePreference.java:49)
... 24 more

mescoda pushed a commit to mescoda/jquery that referenced this pull request Nov 4, 2014
@lock lock bot locked as resolved and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

8 participants