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

Extremely poor performance on iOS UIWebView #72

Open
normanzb opened this issue May 13, 2015 · 8 comments
Open

Extremely poor performance on iOS UIWebView #72

normanzb opened this issue May 13, 2015 · 8 comments

Comments

@normanzb
Copy link

Performance is acceptable in Mobile Safari, but in UIWebView because its using old javascript core, its extremely slow due to the heavily used regular expressions.

http://codepen.io/anon/pen/KpzgKP

You can easily modify the code based on https://github.com/msencenb/UIWebView-Example, point it to above url and run it on real device to see how it performance, it takes minutes to render the page...

@kirbysayshi
Copy link
Owner

Wow that's not good to hear. It will take me some time to get that uiwebview code running. In the meantime, if it's truly the regexes that are slow, have you tried precompiling the templates and shipping those, instead of compiling on page load?

~ Drew

On May 13, 2015, at 4:38 AM, Norman Xu [email protected] wrote:

Performance is acceptable in Mobile Safari, but in UIWebView because its using old javascript core, its extremely slow due to the heavily used regular expressions.

http://codepen.io/anon/pen/KpzgKP

You can easily modify the code based on https://github.com/msencenb/UIWebView-Example, point it to above url and run it on real device to see how it performance, it takes minutes to render the page...


Reply to this email directly or view it on GitHub.

@normanzb normanzb changed the title Extremely bad performance on iOS UIWebView Extremely poor performance on iOS UIWebView May 13, 2015
@normanzb
Copy link
Author

that's a good idea but unfortunately we can't run it from server side at the moment, the function which causes the issue is lexer.advance(), because it loops over all the regex and somehow it triggers JSC::Yarr::matchDisjunction which blocks the whole browser.

a little substr before doing regex.exec() makes it better though, plus caching the template function, it still takes around 10 seconds to finish

@kirbysayshi
Copy link
Owner

To precompile you don't need to run vash on the server, just as part of
your deploy / build script. The CLI tool is a little buggy but it should
work for what you need: https://github.com/kirbysayshi/vash#vash-1 and
https://github.com/kirbysayshi/vash#--target-namespace-

There may be some trickiness with globals (the cli tool assumes vash is
going to be a global... it was 2012 when I wrote it), but let me know if
you have more questions!

Yip yip,
~ Drew*

On Wed, May 13, 2015 at 4:14 PM, Norman Xu [email protected] wrote:

that's a good idea but unfortunately we can't running it from server side
at the moment, the function which cause the issue is lexer.advance(),
because it loops over all the regex and somehow it triggers
JSC::Yarr::matchDisjunction which blocks the whole browser.

a little substr before doing regex.exec() makes it better though, still
taking around 10 seconds to finish


Reply to this email directly or view it on GitHub
#72 (comment).

@normanzb
Copy link
Author

thx for the suggestion, but the situation we have is a little complicated. vash is used as template engine which converts user created template into widgets, because the template is user created... we can't do it on the deployment and because we are bound to some commercial super expensive java CMS system, it will take a while for me to figure out proper server execution of node js or rhino js...

thx anyway, we will do some temporary workaround on our side for now

@kirbysayshi
Copy link
Owner

I did some googling. Since you have a working harness, I'm wondering if you could test something for me:

In tokens.js, could you try removing the 'EMAIL' and the associated regex, and then run your examples again? I believe that's the only one that has nested parenthesis, and that might be forcing the regex to run in interpreted mode instead of compiled / JITed.

@normanzb
Copy link
Author

I already tried that but unfortunately it doesn't help too much...

@kirbysayshi
Copy link
Owner

I am curious: have you seen similar performance problems with other template engines in this older WebView? I wonder how they got around it.

Another idea I had, was you could host a small server that only accepts text and returns a compiled vash template. I assume that's out of the question given java-CMS-land, but wanted to suggest it regardless.

@normanzb
Copy link
Author

Hi @kirbysayshi thanks for the suggestion, we already workarounded it by running the vash in our editor's browser and then save the result to server rather than run it on user's browser.

for the similar performance problems, sorry I haven't tried yet, but I reckon its all about the regexes, if one template use too much regex.exec it will be slow on uiwebview, apple recently released WKWEBVIEW in ios8 which will be much more faster but i guess it needs a while for user and apps to catch up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants