JavaScript on Android. This affects us all

This is a big big issue for us and one everybody should be aware of.

JavaScript on Android is just really slow. I was wondering why my Ionic apps run better on an iPhone 4 than a Nexus 4 or 5. This is it. Android JavaScript is crippled.

Spread the word. This is unacceptable and Google should do something about it.

4 Likes

Noticed this too.

I have an Ionic app which is noticeably (well, a LOT) faster on an iPhone 4S from 2011 than on a Galaxy S3 from 2014 (so, that’s 3 years newer and, according to the specs, much more powerful).

Amazing given the fact that Google produces the most performant Javascript engine (V8) that I know of.

1 Like

Yeah the problem is that google have many products, but each team/product is working in their own universe and not playing together in many ways.

like leop said the v8 engine is great and as base for nodejs it makes a lot of fun to work with.

But combined with the browser/webview on android it is a little bit messing around.

I don’t know what Javascript engine they use in Android (also V8?) but from the Discourse post (https://meta.discourse.org/t/the-state-of-javascript-on-android-in-2015-is-poor/33889) I understand that it’s also (mainly?) a hardware problem.

The chips they use in Android devices are apparently not as good as Apple’s iPhone chips (even though it’s both ARM), or maybe they’re not optimized for stuff that’s important to Javascript performance.

Like I said, performance on Galaxy S3 isn’t bad, far from it, but performance on an iPhone 4S amazed me because everything is just instantaneous - no lag between view transitions, not even a fraction of a second.

the thing of ios devices is, that they are using the gpu more to speed up transitions and rendering processes also for hybrid apps. I read something that android is hardly using the cpu in this area. But maybe i am wrong.

Yes the v8-Engine is the base of the chrome browser and its webview.

Suppose you’re right.

Anyway, when moving between views there’s a small but noticeable “lag” on Android which is absent on iOS.

I suppose this is why people came up with features like “native scrolling” (Native Scrolling: Android Testers Wanted) and “native transitions” (Native View Transition Animations) primarily for Android.

These seem to be unnecessary on iOS (or are even unsupported, which doesn’t matter - you don’t need them).

These are more workarounds than fundamental solutions - issue remains that JS performance is inadequate.

yeah, we have disabled js scrolling in most of our ionic apps, because of lagging (also very frustrating with collection repeat).
On iOS with both --> no problem.

those apps (hybrid) works better on wo 8.1 lumia 535 than on xperia z / asus zenfone 2 and so on :slight_smile:

pssst, you have said the forbidden words wi***** pho**

As much as i hate to disagree with bengtler (not a tiny bit), javascript performance and lack of gpu usage (most of animation related stuff is done on the gpu) is not the problem on android devices, but depth of integration is.

What makes an App feel slow are transitions dropping under 60fps and lagging animations in general. It’s hard maintaining smooth ui under all circumstances. Keep in mind, google provides a framework for thousands of different devices, with a variety of unique preconditions. Compared to iOS, they have a way harder job connecting the low level stuff to the browser and way less possibilities to focus on a specific configuration.

Bengler mentioned that we had to disable js scrolling on newer android devices. This is a good example on how optimization kicks in on a specific problem. Scrolling was always a pain in the ass on android browsers. The old stock android browser was somewhat optimized for js scrolling and did a better job then chrome does today. With mobile chrome being the default rendering engine for the android webview js scrolling sucks, but native scrolling is blazing fast. This is, at least in my opinion, the way better approach anyways.

Diane Hackborn wrote an awesome piece about android performance issues in general a few years ago. This is, in many ways, exactly what’s preventing chrome from being more reliable in terms of performance today!

It’s all about moving pixels, tiny lags, the amount of layers between browser and gpu and the many, many things that can go wrong while rendering a page.

The sad truth is, chrome is not quite there yet in terms of lag free animations using js or css.

I suppose we’re not really talking about “JavaScript” performance, but HTML rendering, hardware accelerated transitions and the like. V8 should be fast enough…

Don’t know … according to this article part of the issue really is Javascript performance or even “V8 optimization”:

https://meta.discourse.org/t/the-state-of-javascript-on-android-in-2015-is-poor/33889

But I’m absolutely not calling myself an expert in this area, far from.

What’s clear though is that iOS devices are tightly controlled (both the software and hardware) by Apple, while Google doesn’t have remotely the same kind of control, and Android devices are way more diverse.

So this shouldn’t really come as that much of a surprise.

Until google do something to improve the JS performance in Android, we still could opt for alternative solution ( temporary ?) such as upgrading the Ionic’s standard web view to Crosswalk web view ( https://crosswalk-project.org/ ). However, the app’s performance still could not match app’s performance in iOS ( it still could not exceed 30 FPS on HD resolution Android phones ). Also, it gave a new problem: the ionic app that is compiled with Crosswalk web view has size that grows to 60-70 megabyte. This is not compelling to users whom notice it. I have heard people talk React Native for android alot nowday. Has anybody tried it before ?

Cheers.

Ionic framework is slow, it is slow in android phones means it is slow. As android phones are 80% of the smart phones out there.

I think you logic is a little flawed.