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

Smarter hardware acceleration #2377

Merged
merged 10 commits into from
Jan 28, 2014
Merged

Smarter hardware acceleration #2377

merged 10 commits into from
Jan 28, 2014

Conversation

mourner
Copy link
Member

@mourner mourner commented Jan 14, 2014

  • Significant improvement to iOS Safari performance — now tiles aren't HW-composited layers (which makes no sense after all), and they're positioned using translate2d. Especially noticeable when pinch-zooming out.
  • this also magically fixes gaps between tiles in desktop Safari, and non-retina tiles don't appear blurry on retina in it as well

I had to resort to a very obscure hack to fix things in Safari — previously the tile layer was stretching weirdly after panning to the right or bottom. After the hack (putting a 1px translated element in the top corner), it doesn't happen much, BUT sometimes still happens, and we need to fix that. Easy way to reproduce is opening vector-simple.html in iPad and pan just slightly south so that new row of tiles gets loaded. It will stretch vertically, but if you keep panning, things will get back to normal. This is driving me nuts.

update: still bugs out on iPhone 5s even with the hack. But what's interesting is that the bug only happens on the first pans, and stops appearing when you pan further. So maybe HW accel switches to some different mode when the element becomes bigger, and we need to figure out how to trigger this mode from the start.
update2: one more clue: doing this hack to force tile container redraw fixes the bugs but introduces flickering.
update3: fixed it with another hack (setting tile containers to 1600 width/height)

Also needs to be tested across devices (I'm especially interested in Android & IE11) — any help appreciated.

cc @danzel @jfirebaugh @tmcw

@danzel
Copy link
Member

danzel commented Jan 14, 2014

Awesome, will test on our IE 10 touch device and get one of the guys to test on their Nexus 5.

@mourner
Copy link
Member Author

mourner commented Jan 14, 2014

Thanks Dave! Also, let me know if you have any ideas about the stretching issue, which is just incredibly weird — there's got to be a way to overcome this... I'd love to make this patch work consistently under iOS.

@danzel
Copy link
Member

danzel commented Jan 14, 2014

IE10 touch seems fine.

Everything seems really bugged on iOS as you say above :S

@mourner
Copy link
Member Author

mourner commented Jan 14, 2014

But try panning further and it stops to be bugged, while still being butter-smooth. Do you see the same behavior?

@danzel
Copy link
Member

danzel commented Jan 14, 2014

Yep, and its really really weird!

@mourner
Copy link
Member Author

mourner commented Jan 24, 2014

OK, it looks like I have found a workaround:

this._tileContainer.style.width = window.screen.width + 'px';
this._tileContainer.style.height = window.screen.height + 'px';
this._tileContainer.style.WebkitTransformOrigin = '0 0';

I was right that it has to do with element dimensions — Safari stops bugging when composited element size comes close to screen size. This makes no sense, but seems to fix all problems. So going to make a commit and ask everyone to test.

@mourner
Copy link
Member Author

mourner commented Jan 24, 2014

Nope, I was wrong, iPhone still bugs out :(

@mourner
Copy link
Member Author

mourner commented Jan 24, 2014

BUT, iPhone doesn't bug out if you set the size to bigger values like 1440, 900, LOL. Apparently there's some weird hack in Safari HW code somewhere.

@mourner
Copy link
Member Author

mourner commented Jan 27, 2014

OK, this should be good to go pretty much. Works well for me on iPhone 5s, iPad 2 & Safari OS X.
@danzel I eventually changed the code to always use top/left for tiles so that individual tiles are not HW-composited. Combined with removing webkitBackfaceVisibility hack (which should only be applied on Android), it seems to perform as smoothly on Chrome, while iOS & Safari behave less buggily. Please check that out.
One more win is that Safari now shows crisper non-retina tiles on retina.

@ghost ghost assigned mourner Jan 27, 2014
@danzel
Copy link
Member

danzel commented Jan 27, 2014

What does chrome on iOS get identified as?
It probably wants the same things as safari on iOS since it just uses the native webkit.

Fiddling now :)

@danzel
Copy link
Member

danzel commented Jan 27, 2014

Seemed good in my testing, even chrome on iOS worked fine.

@mourner
Copy link
Member Author

mourner commented Jan 27, 2014

Nice! @danzel did you also notice a performance improvement in your testing?

@danzel
Copy link
Member

danzel commented Jan 27, 2014

I don't have any old devices on hand to test with, everything seemed super smooth.

mourner added a commit that referenced this pull request Jan 28, 2014
Smarter hardware acceleration
@mourner mourner merged commit bce7c49 into master Jan 28, 2014
@mourner mourner deleted the accel branch January 28, 2014 11:22
mourner added a commit that referenced this pull request Jun 4, 2015
This kind of reverts #2377 that doesn’t make sense after tile animation
refactorings, because it makes Safari terribly slow. It reintroduces
the tile gaps, but oh well, we choose the lesser evil here.

Also, performance in latest iOS is the same with and without the patch
so there’s no harm in removing this.
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

Successfully merging this pull request may close these issues.

2 participants