CSS animation crashes Phonegap App on iPad only - javascript

My Phonegap App I am using High resolution images and zooming functionality using iScroll. But it looks blur so i got one solution add css translate. It solves my image blur issue but in iPad2 my App crashes due to this css transform.
transform: translate3d(0,0,0);
-webkit-transform: translate3d(0,0,0);

#Krishna,
Those specific CSS strings transform: translate3d(0,0,0); are used to turn on hardware acceleration. At least, that is what I read again and again. If you know that they are making you App crash, take them out. I don't see the issue.
The answer to your blurring, try something else - like increasing your pixel density.

Related

Is there a way I can force chrome to do subpixel rendering for a slow translation?

Im doing a very slow transition of a background image (a view of space that slides slowly to the left). My problem is while it looks beautiful on Firefox, it looks horrible on Chrome. I get a "jittery" effect due to Chrome's lack of subpixel rendering, and the image just snaps to the next pixel. I cannot speed the image up because it will destroy the effect Im trying to achieve. I have tried using TranslateZ() tricks, I have tried every CSS3 effect I could think of to make it look better, Ive tried Kinetic.js, Ive even tried Babylon.js hoping that WebGL would fix my problem.
At this point Im at a loss and I might just have to give Chrome users a static background and cater more to the Firefox users in regards to the neat little things I can do for the UI UX, and then just put a disclaimer on my site saying that the page is best viewed in FF.
I REALLY dont want to do this. Is there ANY work around at all?
You can force subpixel rendering by applying a small transformation:
#container {
transform: rotate(-0.0000000001deg);
-webkit-transform: rotate(-0.0000000001deg);
}
But instead of using JS to make the animation work, why not use CSS3 animations?
If you use transform: translate() browsers will use subpixel-rendering by default.
Also since the performance is better you shouldn't get your jittery/wave motion.
More info on performance here: http://www.paulirish.com/2012/why-moving-elements-with-translate-is-better-than-posabs-topleft/
I've put together a simple demo here: http://jsfiddle.net/yrwA9/6/
(For the sake of simplicity I only used the -webkit- vendor prefixes)

CSS3 Flickering in Safari 6 on OSX (but this is not the flickering-to-white issue!)

This issue does not present on iOS or on Chrome so it is not a Webkit related issue. It seems to be specific to the latest Safari 6.0.2 on OS X 10.8.2 (and not fixed by 10.8.3 preview build 12D65 which comes with Safari 6.0.3). I shall test on Lion 10.7.5 with Safari 6.0.2 shortly, and will also be testing on preview build 12D68 as well.
http://jsfiddle.net/zrr2b/
Here is a fiddle that makes the problem quite apparent. If you've got a Mac running ML, you should see a significant difference between Chrome and Safari where Safari flickers a lot as you move the mouse around.
Basically the problem is that Safari will intermittently draw the target transform being set from JS for a single frame, then continue the transition animation. This causes a flicker, but only if the transition was in the middle of going somewhere to begin with. So the bug won't rear its ugly head for most (non intensive use) of CSS3 transition, but if functionality or visual effects depend on it to smoothly interpolate to a target (as my current project does) this flicker is not pleasant.
I have looked at similar topics related to flickering and applied pretty much all combinations of styles to counteract flickering, such as the -webkit-backface-visibility: hidden, forcing various parent elements to gain hardware acceleration, -webkit-transform-style: preserve-3d, -webkit-perspective: 1000, and none of them unfortunately do anything to address this Safari-specific problem of flickering, that is, flickering not to white or blank, but flickering to the target transform for a single frame.
Here in this branch you can see me set a bunch of styles that help with "regular flickering" but have no effect for me. http://jsfiddle.net/zrr2b/1/
As this is not a webkit specific issue I am unsure where to go about posting a bug report. It would be especially nice to get this in before 10.8.3 release since I see this as a rather big issue. Remember, this is the sort of thing that we're depending on HTML5 to do well in order for it to really kill Flash.
Updates:
Safari Version 6.0.3 (8536.28.10) on Mountain Lion 10.8.3 12D68 (Retina Macbook Pro 15.4") still suffers from this issue
Safari on Windows (5.1.7) does not suffer from this bug
Safari Version 6.0.2 (7536.26.17) on Lion 10.7.5 (Macbook Air Mid 2011) does not suffer from this bug
There are a few different ways of experimenting with reducing the flickering. The big problem however, it's that they seem to be "hit and miss". So you got to try a few to see which one helps resolve the issue.
But they center around the same few things:
-webkit-transform: translateZ(0); /* triggers GPU, sometimes fixes the issue */
transform: translateZ(0); /* non-webkit specific */
If this doesn't quite do the trick, try:
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-perspective: 1000;
perspective: 1000;
If this also fails, try this:
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
You can read about each one of them through the W3C. But they have all worked for me on different circumstances with not fluid animations, and flickering ones, including some very odd ones, a lot jumpier than your fiddle.
They would go in the div being animated.

The most accelerated javascript snow

I have saw a lot of them, but all they look not accelerated and slow.
For instance:
http://www.schillmania.com/temp/snowstorm/
http://sebleedelisle.com/demos/JSSnow/snow3d.html
Is it possible at all to have a script that will be smooth enough on iPhone 4 / typical Android device (like Kindle Fire)?
Regards,
UPDATE
Thanks to Julian D.! designshack.net/?p=27674 is awesome! No scripts at all, pure CSS, several layers are moving in different directions. Some tips:
Layer's patterns should be small enough (<=300px),
There should be NO color animation (remove it from -webkit 50% and 100% keyframes),
Use 2 layers instead of 3,
Add -webkit-transform: translateZ(0); for all keyframes, see HTML5 transition perfomance on iPhone 4 for details, thanks to mikeyUX.
20s is too smoothly, use 10s.
With all these tips it's fast enough on iOS (iPod 4 Touch) to be used in a real project.
If you are talking about hardware accelerated animations you want to look at CSS Keyframe Animation-based solutions, e.g.
http://designshack.net/?p=27674
http://natbat.net/code/clientside/css/snowflakes/
Here is a tutorial how to do
- http://girliemac.com/blog/2009/02/18/using-keyframes-webkit-css-animation-examples/
Still, your mileage may vary. Some Android devices/version don't support hardwarde acceleration at all, you are out of luck here.

iPad css3 animation flickers after keyboard use

I'm developing an app for the iPad using HTML5/CSS3. I'm not using any framework and am just using whatever is natively supported on the device. I have created some css3 animations to emulate the typical iOS sliding left or sliding right when navigating between screens. Here's an example of the slide left animation which is taking advantage of the iPad's CSS3 hardware acceleration: (the ipad is running 4.2).
/*************************************************
Slide Left
*************************************************/
.screen.slideleft{
-webkit-animation-duration: 0.5s;
-webkit-animation-timing-function: ease-in-out;
}
.screen.slideleft.outgoing{
z-index: 50 !important;
-webkit-animation-name: slideleft-outgoing;
}
.screen.slideleft.incoming{
z-index: 100 !important;
-webkit-animation-name: slideleft-incoming;
}
#-webkit-keyframes slideleft-outgoing{
from { -webkit-transform: translate3d(0%,0,0); }
to { -webkit-transform: translate3d(-100%,0,0); }
}
#-webkit-keyframes slideleft-incoming{
from { -webkit-transform: translate3d(100%,0,0); }
to { -webkit-transform: translate3d(0%,0,0); }
}
I also have this CSS which I've attempted to use to fix the flicker:
.incoming,
.outgoing{
display: block !important;
-webkit-backface-visibility: hidden;
}
This works great until the iPad keyboard is used. After which point all the animations flicker severely.
I've been looking for examples of an iPad HTML5 app that uses the keyboard and doesn't have flickers afterwards, but haven't turned up much. The jqTouch demos exhibit the same behavior on the iPad (although I know they were designed for the iPhone).
I've turned up a few posts/questions of similar questions but have never found a good answer. I've been through http://css3animator.com/2010/12/fight-the-flicker-making-your-css3-animation-bomb-proof/ and the articles linked there but haven't had any success.
Any other suggestions?
Update 1/13 # 9am
I've added this css and it helped a lot:
.incoming *,
.outgoing *{
-webkit-backface-visibility: hidden;
-webkit-transform: translate3d(0,0,0); /* This helps with the flicker a lot. */
}
The foreground elements don't seem to flicker anymore, but the backgrounds still do. Still looking for some help or helpful resources on Mobile Safari's memory handling tactics.
Update 1/16 # 11pm
Increasing the z-index as suggested by anonymous. Didn't seem to make a difference.
Update 1/17 # 8:30am
I've posted a demo of the problem here.
The transitions between screens work great...until you tap/click inside one of the form fields. After the keyboard slides up and returns, all the transitions flicker. Go to the URL inside the iOS simulator or on an actual iPad to see what I'm talking about.
This is an old question, but I thought I'd share my experience.
I've been having issues with outrageous flickering (on css3 animations) on the iPad (as well as the iPhone, but in that case only in portrait view). I was able to completely resolve all of the flickering issues by setting :
-webkit-perspective: 0;
On the elements being animated. I'm not sure why this works, but it does (tested on iOS 4.2+, both iPad (1 and 2) and iPhone 4).
Update: I've just become aware of an issue with Chrome when setting the value of that attribute to 1. It works just fine when it's 0, so I've updated the above appropriately.
Looking at your source, the translate3d(0,0,0) isn't applied until the transition starts?
Try
.screen{
-webkit-transform: translate3d(0,0,0);
}
or
.screen *, .screen{
-webkit-transform: translate3d(0,0,0);
}
The flicker is probably the hardware acceleration kicking in (it currently only works on 3d translated elements).
I had the same issue, but i was able to reduce the flicker to almost unnoticeable by applying the fix described here and here:
http://code.google.com/p/jqtouch/issues/detail?id=301
https://github.com/senchalabs/jQTouch/issues/issue/130
Basically set the z-index of the page you a are moving out to -1 and after the transistion back to 1
I know this is a dinosaur old question, but there is a solution for this issue and it is quite lightweight and very simple.
document.getElementById('clicked_input').addEventListener('focus', function(e){
e.stopPropagation();
},false);
When i was tackling this issue too, I thought I tried everything - eventually the only thing that helped, was to create a modal window (position: absolute) outside of the app's container div, and also set the app's container div to display:false; when the keyboard was coming up. While it worked it was ugly, I tested everything to see what caused the event and it seemed that when the 'focus event' bubbled up, every 3d transform gets messed up (in flickering and performance).
Preventing the event of bubbling solved this issue completely - quite mind boggling that such a hated bug had such a simple solution?
You're not going to like me saying this, but JavaScript may be the answer you're looking for. I fear that when you bring the keyboard up, the process of rendering the HTML loses priority. With a continually updating script, like a setInterval loop, the iPad will have no choice but to render as planned. Explicit code requires no hacks.
I agree with Ben, you should probably set transforms on the classes themselves as well:
/*************************************************
Slide Left
*************************************************/
.screen.slideleft{
-webkit-animation-duration: 0.5s;
-webkit-animation-timing-function: ease-in-out;
-webkit-transform: translate3d(0,0,0);
}
.screen.slideleft.outgoing{
z-index: 50 !important;
-webkit-animation-name: slideleft-outgoing;
-webkit-transform: translate3d(-100%,0,0);
}
.screen.slideleft.incoming{
z-index: 100 !important;
-webkit-animation-name: slideleft-incoming;
-webkit-transform: translate3d(0,0,0);
}
#-webkit-keyframes slideleft-outgoing{
from { -webkit-transform: translate3d(0,0,0); }
to { -webkit-transform: translate3d(-100%,0,0); }
}
#-webkit-keyframes slideleft-incoming{
from { -webkit-transform: translate3d(100%,0,0); }
to { -webkit-transform: translate3d(0,0,0); }
}
If that doesn't work, I'd be curious to test if only translating the X with translateX(-100%) fixes the problem. (Not necessarily a fix, because you don't have hardware acceleration without 3D transforms, but would help narrow down the problem.)
Ultimately, there really wasn't a fix for this issue. It seems like form elements in WebKit on the iPad cause problems with flickering.
My workaround was that on the onblur of each form element, I refreshed the page using hash tags to ensure it refreshed to the exact same state. It still caused a "flicker" while it was refreshing, but it did keep the screen from flickering throughout the rest of the app.
I've recently been having the same problem and tried all sorts of complicated fixes. In the end I found the issue was down to the default styling on the input. I fixed my problem by adding the css input{outline:none}. It's prob just on the focus state so input:focus{outline:none;} should work.

How to rotate an image using client side solution

I am wondering if there is any way to dynamically rotate an image or invert an image using a client side solution? I don't care if it is plain old javascript, jquery plugin, css. I just wondered if there was some way to do this dynamically on the client side rather than having to write server side code to do for each image which I can do.
I tried searching on Google for different keywords but couldn't find anything.
EDIT: I am looking for a solution that does not require anything from HTML 5.
Firefox, Safari and Opera support this:
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
-o-transform: rotate(-90deg);
transform: rotate(-90deg);
you can also do this in IE8, maybe even 7(?):
position: absolute;
filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
rotate an element using JS:
var deg = 90
$('element').style.MozTransform = 'rotate(' + deg + 'deg)';
$('element').style.WebkitTransform = 'rotate(' + deg + 'deg)';
edit:
wow, according to http://msdn.microsoft.com/en-us/library/ms532972%28VS.85%29.aspx the rotation works for IE 5.5!
Very interesting javascript solution:
http://www.stableflow.com/downloads/jquery-plugins/360-degrees-product-view/
Imagine that you are running some shop or blog and you present user with your products. The solution allows you to save space and present products view in very realistic form by means of the script. It allows to forget about flash (which is still not supported by all mobile devices).
What you need to utilize it is:
Download free plugin (use link above)
Setup the plugin using instructions
Create and add a series of images for each product (the more images the better rotation effect you will get)
Follow raised interest to your products from users
It really worked for me. Tested on Android mobile(lg p500), iPad and iPod touch as well.
You can do it using the canvas element, as shown here. I'm not 100% sure all browsers support it already. It is part of HTML5 (read more about it on Wikipedia), so FF, Safari and Chrome support it. Not sure about IE8.

Categories