rich Posted May 22, 2013 Share Posted May 22, 2013 Since Android 4.1.2 we've noticed an annoying issue in the stock browser that effects a number of games (not just ours) specifically on Samsung devices. Basically when you touch the display, the game will freeze. It literally pauses for a while before carrying on. Almost as if it's expecting some kind of gesture, or trying to save an image or something. The delay is quite noticeable. I wonder if it's a change with listening for mouse/touch events? We've seen this happening across all Samsung devices we tested on (S3, S2, Galaxy Ace, etc) but only on Android 4.1.2. Quote Link to comment Share on other sites More sharing options...
remvst Posted May 22, 2013 Share Posted May 22, 2013 Got the same issue when BoosterMedia was testing one of my games on a Galaxy S2. I wasn't able to reproduce the problem since I don't have one, and I can't borrow my roommate's phone too often :-p Maybe you should take a look at this: http://stackoverflow.com/questions/10246305/android-browser-touch-events-stop-display-being-updated-inc-canvas-elements-hThe solution requires to add a preventDefault() call on touch events on the document. I never knew if it worked for me though Quote Link to comment Share on other sites More sharing options...
Ezelia Posted May 22, 2013 Share Posted May 22, 2013 some users reported a similar behaviour to me too, but since I was not able to reproduce it I didn't asked for the OS version :/ Quote Link to comment Share on other sites More sharing options...
rich Posted May 22, 2013 Author Share Posted May 22, 2013 preventDefault doesn't fix it. I've got an S2 and an S3 here and they both now do this, having been upgraded. Quote Link to comment Share on other sites More sharing options...
remvst Posted May 22, 2013 Share Posted May 22, 2013 preventDefault doesn't fix it. I've got an S2 and an S3 here and they both now do this, having been upgraded.Is it only the canvas update that freezes, or does the game loop freeze too ? Quote Link to comment Share on other sites More sharing options...
rich Posted May 22, 2013 Author Share Posted May 22, 2013 Just the canvas update. When the game resumes it's as if you had been playing it normally, so frames jump ahead quite a lot. Quote Link to comment Share on other sites More sharing options...
remvst Posted May 22, 2013 Share Posted May 22, 2013 Well I don't really know what to say, except removing all event listeners and adding only the preventDefault() ones to see what happens. Quote Link to comment Share on other sites More sharing options...
rich Posted May 22, 2013 Author Share Posted May 22, 2013 Yeah I feel this will be a late night of debugging heading my way. Bloody Android! Quote Link to comment Share on other sites More sharing options...
mentuat Posted May 22, 2013 Share Posted May 22, 2013 ya I just noticed this when popping into carphone warehouse to do some testing today - both a samsung tab 2 and an S3 mini had same freezing issue with stock browser (chrome was fine). A normal S3 right next to the mini was fine. Didn't see this problem on any other device/browser combinations. preventDefault did not prevent the freeze and my listeners were: touchstart, mousedown, touchend, mouseup Quote Link to comment Share on other sites More sharing options...
remvst Posted May 22, 2013 Share Posted May 22, 2013 ya I just noticed this when popping into carphone warehouse to do some testing today - both a samsung tab 2 and an S3 mini had same freezing issue with stock browser (chrome was fine). A normal S3 right next to the mini was fine. Didn't see this problem on any other device/browser combinations. preventDefault did not prevent the freeze and my listeners were: touchstart, mousedown, touchend, mouseuptouchmove is probably more important. Did you try? Quote Link to comment Share on other sites More sharing options...
mentuat Posted May 22, 2013 Share Posted May 22, 2013 I'll test it tomorrow - my device testing involves a round trip to the local shopping centre Quote Link to comment Share on other sites More sharing options...
aholla Posted May 22, 2013 Share Posted May 22, 2013 Could it be related the to the clearRect bug: http://www.html5gamedevs.com/topic/114-canvasclearrect-bug-in-android-stock-browser/ I have had so many problems with the stock browser, performance on an S3 is so much worst than an ipad 1. Good luck luck. Quote Link to comment Share on other sites More sharing options...
mentuat Posted May 29, 2013 Share Posted May 29, 2013 I finally have an android device to test with and after faffing about for hours I still can't solve this. I've checked a few html 5 games on the web and most seem to have the same freeze issue - I noticed that a few games made with createjs seem to be immune so I had a peek at how it was dealing with touch events couldn't see anything too different to what I was already doing - but I plumbed in the touch code from easeljs to see if it would make a difference (to no avail - still freezes). Not sure what else in the use of createjs is making it work without further investigation I also tried overriding all touch commands at the document level and applying the game touch events to a div but no difference I wondering if it's something set in the html causing the issue - a style or viewport parameter? what I'm surprised about is that there is very little information about this on the web for what seems like a real deal breaker for anyone making games/interactive content for android Quote Link to comment Share on other sites More sharing options...
rich Posted May 29, 2013 Author Share Posted May 29, 2013 Samsung have confirmed it as an issue: http://developer.samsung.com/forum/board/thread/view.do?boardName=GeneralB&messageId=235672 If you could register and add your voice to the thread that would be useful! We need to know how to fix this, or if we can't when they're going to. Quote Link to comment Share on other sites More sharing options...
mentuat Posted May 29, 2013 Share Posted May 29, 2013 have added a post, nice to see Jon Howard on there! Quote Link to comment Share on other sites More sharing options...
mentuat Posted June 2, 2013 Share Posted June 2, 2013 So it seems that Samsung's response is to suggest using chrome instead! Excellent - those guys are really on top of their game Quote Link to comment Share on other sites More sharing options...
eriksom Posted November 25, 2013 Share Posted November 25, 2013 Hi Guys, im running content for www.a10.com (m.a10.com, t.a10.com)Is there already a fix for this particular problem? We notice similar behavior for some of our games.A big portion of our users are running android 4.1.2 using stock browser.Would be happy to hear back from you.Regards Quote Link to comment Share on other sites More sharing options...
inductible Posted November 26, 2013 Share Posted November 26, 2013 I've recently run into this, and drawn up a blank - no idea how to resolve it: http://www.bbc.co.uk/cbeebies/tee-and-mo/games/tee-and-mo-face-painting/http://www.bbc.co.uk/cbeebies/tee-and-mo/games/tee-and-mo-picture-perfect/ I investigated a DOM rendered alternative approach, because I can see in my case that another DOM rendered CSS anim occurring on touch move was still correctly rendering. This turned out to be inconclusive until I had to park things for another day though. Quote Link to comment Share on other sites More sharing options...
rich Posted November 26, 2013 Author Share Posted November 26, 2013 There's no fix. I guess Samsung don't care because 4.1.2 is "old" for them now. None of their current phones ship with that version (and haven't done for months now). None of my Samsung devices have 4.1.2 on any more, they've all auto-updated now. I suspect it was just some stupid bug in stock browser they fixed some time ago. They are always doing daft things in their browser, this is just one of many Samsung related issues. Quote Link to comment Share on other sites More sharing options...
geograman Posted March 2, 2014 Share Posted March 2, 2014 I actually solved this issue accidentaly... but its not logical at all :/Mentuat's guess was right. Obviously it has something to do with set Viewports and CSS. I am not sure why it is working but i'll give you what IS working. If found out the following. 1: Don't give the canvas an absolute position or even better no css styles at all.2: Leave any PARENT elemnts css default, leave everything default no css reset NOTHING !3: Set the Viewport like <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />4. You can set the canvas position relative to alter its position5. You can set absolute positioned controll buttons or anything onto the canvas should still work So basicaly if you dont know why it is not working... just create a clear HTML5 page with NO CSS AT ALL !!! and just set html width/height and add the viewport meta tag as given Would like to hear more about this from you guys Quote Link to comment Share on other sites More sharing options...
Blank101 Posted July 2, 2014 Share Posted July 2, 2014 I've solved this problem in my games by including this in the <head>:<meta name='viewport' content='width = device-width, initial-scale=1, maximum-scale=1.01' /><script>window.addEventListener("load", function() { function onTouchPreventDefault(event) { event.preventDefault(); }; document.addEventListener("touchmove", onTouchPreventDefault, false); document.addEventListener("touchstart", onTouchPreventDefault, false);}, false);</script>I've tested this on my S3 stock browser and it works fine now. Without the code I get canvas freeze on tap. mentuat 1 Quote Link to comment Share on other sites More sharing options...
lukaMis Posted July 2, 2014 Share Posted July 2, 2014 I've solved this problem in my games by including this in the <head>:<meta name='viewport' content='width = device-width, initial-scale=1, maximum-scale=1.01' /><script>window.addEventListener("load", function() { function onTouchPreventDefault(event) { event.preventDefault(); }; document.addEventListener("touchmove", onTouchPreventDefault, false); document.addEventListener("touchstart", onTouchPreventDefault, false);}, false);</script>I've tested this on my S3 stock browser and it works fine now. Without the code I get canvas freeze on tap. Has this any effect on other browsers like Chrome...? Quote Link to comment Share on other sites More sharing options...
mentuat Posted July 2, 2014 Share Posted July 2, 2014 does seem to work well - nice one! edit: on further testing, it's effective on stock browser on Samsung S3 mini with Android 4.1.1 (and the only part needed was 'maximum-scale=1.01') Unfortunately the trick doesn't work on a Samsung Tab 2 with 4.1.1 odd! Quote Link to comment Share on other sites More sharing options...
Blank101 Posted July 2, 2014 Share Posted July 2, 2014 Has this any effect on other browsers like Chrome...? I haven't seen any adverse effects in either Android Chrome or iOS Safari. Quote Link to comment Share on other sites More sharing options...
Blank101 Posted July 2, 2014 Share Posted July 2, 2014 does seem to work well - nice one! edit: on further testing, it's effective on stock browser on Samsung S3 mini with Android 4.1.1 (and the only part needed was 'maximum-scale=1.01') Unfortunately the trick doesn't work on a Samsung Tab 2 with 4.1.1 odd! Very odd. Gotta love the stock browser... True about the maximum scale. Just be sure to preventDefault on the event if you arn't using Phaser. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.