<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>indiegamr &#187; css</title>
	<atom:link href="http://indiegamr.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://indiegamr.com</link>
	<description>apps, indie &#38; beyond</description>
	<lastBuildDate>Sun, 30 Mar 2014 14:51:19 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>iOS html5 performance issues #2: scrollpanes and hardware acceleration</title>
		<link>http://indiegamr.com/ios-html5-performance-issues-with-overflow-scrolling-touch-and-hardware-acceleration/</link>
		<comments>http://indiegamr.com/ios-html5-performance-issues-with-overflow-scrolling-touch-and-hardware-acceleration/#comments</comments>
		<pubDate>Tue, 13 Nov 2012 06:41:22 +0000</pubDate>
		<dc:creator><![CDATA[olsn]]></dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://indiegamr.com/?p=509</guid>
		<description><![CDATA[Don&#8217;t try to force hardware acceleration on elements that are placed on a touch-scroll-pane! &#8230;and here&#8217;s why: I personally love the  &#8216;-webkit-overflow-scrolling: touch&#8217;-feature as it allows you to implement a scroll pane for mobile devices with just writing two lines of &#8230; <a href="http://indiegamr.com/ios-html5-performance-issues-with-overflow-scrolling-touch-and-hardware-acceleration/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><strong>Don&#8217;t try to force hardware acceleration on elements that are placed on a touch-scroll-pane!</strong> &#8230;and here&#8217;s why:</p>
<p>I personally love the  &#8216;-webkit-overflow-scrolling: touch&#8217;-feature as it allows you to implement a scroll pane for mobile devices with just writing two lines of css and no need of hasseling around with JS to make some content scroll smooth ect., however this approach also comes with a drawback: hardware acceleration will cause performance-issues on iOS (maybe other mobile devices, though it was only tested on an iPad2 running iOS6)</p>
<p>In my last post I was writing about forcing html5 hardware acceleration on iOS6, turns out you do NOT want to do that on every element as this can also cause the performance to drop, pointed out by the following example:<br />
<span id="more-509"></span><br />
The scenario is the following: The base is a big scrollpane using &#8216;<span style="font-family: 'Courier 10 Pitch', Courier, monospace !important;">-webkit-overflow-scrolling: touch</span>&#8216; that contains many images that are scaled from 100px width to 50px width.<br />
When combining this with forced hardware acceleration it will cause a massive drop in fps while scrolling.</p>
<p>Try it yourself by pointing your mobile browser to the following urls:<br />
<strong>Images Example</strong> <a href="http://labs.indiegamr.com/touch_scroll_performance/plain_images_nonaccel.html" target="_blank">Version 1: http://goo.gl/XIn9e</a> &#8211; NOT hardware accelerated, very good framerate<br />
<strong>Images Example</strong> <a href="http://labs.indiegamr.com/touch_scroll_performance/plain_images_accel.html" target="_blank">Version 2: http://goo.gl/DKC1u  </a>- hardware accelerated, low framerate while scrolling, however seems not to affect the execution of JS as the displayed fps does not drop</p>
<p>The only difference between Version 1 and Version 2 is:</p><pre class="crayon-plain-tag">img {
 -webkit-transform: translateZ(0);
 -webkit-perspective: 1000;
 -webkit-backface-visibility: hidden;
}</pre><p>The examples with HTMLImages shows a very huge drop in performance, however this effect is not solely limited to images but also &lt;div&gt; and other elements, even though it takes a larger number of divs to bring down the performance this way, it is possible:</p>
<p><strong>Divs Example</strong> <a href="http://labs.indiegamr.com/touch_scroll_performance/divs_nonaccel.html">Version 1: http://goo.gl/1iF71</a> &#8211; NOT accelerated, fluid, high fps<br />
<strong>Divs Example</strong> <a href="http://labs.indiegamr.com/touch_scroll_performance/divs_accel.html">Version 2: http://goo.gl/qkdwm</a> &#8211; accelerated, less frames on scrolling, seems to affect the execution speed of JS code</p>
<p>So bottom line: Forced hardware acceleration and <span style="font-family: 'Courier 10 Pitch', Courier, monospace !important;">&#8216;-webkit-overflow-scrolling: touch;&#8217;</span> do not work together very well!</p>
]]></content:encoded>
			<wfw:commentRss>http://indiegamr.com/ios-html5-performance-issues-with-overflow-scrolling-touch-and-hardware-acceleration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iOS6 html hardware acceleration changes and how to fix them</title>
		<link>http://indiegamr.com/ios6-html-hardware-acceleration-changes-and-how-to-fix-them/</link>
		<comments>http://indiegamr.com/ios6-html-hardware-acceleration-changes-and-how-to-fix-them/#comments</comments>
		<pubDate>Sun, 30 Sep 2012 13:42:05 +0000</pubDate>
		<dc:creator><![CDATA[olsn]]></dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://indiegamr.com/?p=485</guid>
		<description><![CDATA[As probably many developers have already experience this over the past weeks: I had a phonegap application for iOS that contained some visually animated components  (a coverflow or a carousel for example). But after updating to iOS6 this is all &#8230; <a href="http://indiegamr.com/ios6-html-hardware-acceleration-changes-and-how-to-fix-them/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>As probably many developers have already experience this over the past weeks:<br />
I had a phonegap application for iOS that contained some visually animated components  (a coverflow or a carousel for example). But after updating to iOS6 this is all flickring now and it feels horrible because it&#8217;s just stumbling and faltering on the new version of the OS.<br />
There are several reasons for this and I cannot say which were already there in iOS5, however here are the two main reasons and instructions on how to fix that:<span id="more-485"></span></p>
<h2>1. Not all CSS Properties trigger hardware acceleration any more</h2>
<p>Previously there were quite a few properties that triggered a hardware acceleration, for example:</p>
<ul>
<li>-webik-transform: translate3d(x,y,z);</li>
<li>-webkit-transform: preserve-3d;</li>
<li>&#8230;</li>
</ul>
<p>As Apple states in its <a href="http://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/_index.html#//apple_ref/doc/uid/TP40012166-CH1-SW19" target="_blank">Developer Changelog for iOS6</a>: &#8216;<em>WebKit no longer always creates hardware-accelerated layers for elements with the <code>-webkit-transform: preserve-3d</code> option.[&#8230;]</em>&#8216; There is a need for new CSS properties to trigger the acceleration, unfortunately I&#8217;m not aware of any official document by Apple listing those properties.</p>
<p><strong>How to fix it:</strong><br />
Here are three properties that have been proven to work (at least in combination, I have not yet tested them solo, but they should):</p>
<ul>
<li>-webkit-transform: translateZ(0);</li>
<li>-webkit-perspective: 1000;</li>
<li>-webkit-backface-visibility: hidden;<a href="http://indiegamr.com/ios6-html-hardware-acceleration-changes-and-how-to-fix-them/ios6-performance-overlapping/" rel="attachment wp-att-489"><br />
</a></li>
</ul>
<p>As this is going to trigger hardware acceleration for the specified elements this might still not completely fix all the issues, therefore please continue reading Nr.2.</p>
<hr />
<h2>2. Overlapping with other Elements</h2>
<p>Since I cannot downgrade to iOS5 I cannot say for sure if this &#8220;issue&#8221; already persisted, however it heavily persists with iOS6:<br />
<a style="font-style: normal; line-height: 24px; text-decoration: underline;" href="http://indiegamr.com/ios6-html-hardware-acceleration-changes-and-how-to-fix-them/ios6-performance-overlapping/" rel="attachment wp-att-489"><br />
</a>If you have an element(Element A) that is hardware accelerated and animated, it will/might cause performance and visual issues when overlapping with other elements(Element B) that are not hardware accelerated, as Element A will trigger Element B to be re-rendered with every change of Element A(at the end of a CSS-transition or when updating CSS properties through JS), which will cause:</p>
<ul>
<li><strong>flickering of Element B, since it renders a lot slower</strong></li>
<li><strong>heavy slowdown of the animation, since it needs more CPU time to render leaving less time for JS execution</strong></li>
</ul>
<p>One thing I noticed: If Element A OVERlaps another element it is not slowing down the animation as heavy as if Element A was UNDERlapping another element. Also it does not really matter if the parent-container of Element A has &#8216;overflow: hidden;&#8217; or &#8216;overflow: visible;&#8217; &#8211; it still slows doen the execution if the overlapping occures outside the bounds of the parent container.</p>
<p><strong>How to fix it:<br />
</strong> a) This can be simply fixed by giving ALL overlapping elements the CSS properties that trigger hardware accerleration. (<strong>see 1.</strong>)<br />
(My first approach to fix this was by alternating the DOM-order to only have OVERlapping elements, however fix a) is way easier and works way better &#8211; for me.)</p>
<p>I have visualized this here:<a href="http://indiegamr.com/ios6-html-hardware-acceleration-changes-and-how-to-fix-them/ios6-performance-overlapping/" rel="attachment wp-att-489"><img class="aligncenter size-full wp-image-489" title="ios6-performance-overlapping" src="http://indiegamr.com/wp-content/uploads/ios6-performance-overlapping.png" alt="" width="768" height="400" /></a></p>
<p>&nbsp;</p>
<p>edit1: 16-10-2012</p>
<hr />
<h2>3. Avoid changes between &#8216;display: none;&#8217; and &#8216;display: something;&#8217;</h2>
<p>Changing the display-state on iOS is like adding or removing an element to and from the DOM and is therefor a very heady calculation depending on how many items you have in your DOM that can easyly cause the UI to freeze for a second or more.</p>
<p><strong>How to fix it:</strong><br />
Instead of using the display-property, use the tranform-property instead, if you want to hide an item you can use something like this: transform:</p><pre class="crayon-plain-tag">translate(100000px,100000px);</pre><p>and if you want to show the element, just set the values to 0:</p><pre class="crayon-plain-tag">translate(0px,0px);</pre><p>You have to set the &#8216;position: absolute;&#8217; though. This method needs a little bit more work than using &#8216;display&#8217;, however the performance of your webapp will thank you greatly for that.</p>
<p>&nbsp;</p>
<p>I hope this helps someone as I was struggeling with this issue for quite a while, thoughts or additions on this article are very welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://indiegamr.com/ios6-html-hardware-acceleration-changes-and-how-to-fix-them/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
	</channel>
</rss>
