Screen misaligned after device wake up (Android BUG) My solution

izamizam Member, PRO Posts: 503

I'm sure those of you who publish to android will know this BUG.
In the midst of playing your game, you let the device sleep. After several seconds you wake it up, the game comes on but... OH NO! What is this I see? The screen has misaligned (camera is out of alignment) and your player thinks very lowly of you for being such a bad developer. There it is, another 1 star nailed on the ranking board.

This bug has been around since june/july 2015 and has been one of the many causes for my game NOT being featured on google play store by the play store's editors/reviewers.

I just thought of a solution to this, not very elegant but it goes basically like this:

Have a detection method in one of your actors that will detect all these:

1) if "touch is not active"
2) if scene camera x position and y position is not at your originally set position

then the execute this behaviour:
after 0.1 sec (do not check run to completion) change the scene camera x and y position to your originally set position.

That's it. Try it out and hopefully this will solve it while we wait for GS to fix this and other problems on Android.

«1

Comments

  • SLOCM3ZSLOCM3Z Member Posts: 797

    Nice!

  • bloodnitebloodnite Member Posts: 50
    edited July 2016

    Is this still needed? If so ... I'm not seeing a specific item to constrain against for scene x/y position, just width/height... am I missing something or was this fixed? This seems like the same issue I'm having where on my kindle or android phone it hibernates and when waking up or unlocking the screen, it shows the camera off center and looks completely retarded and unusable. Can someone point me in the right direction on this?
    *I'm using the latest Windows creator pro version.

  • bloodnitebloodnite Member Posts: 50

    Would the rules be this...?

    The idea is to lock the camera to the screen size to the game wont be zoomed/shifted/unplayable. No movable players, just a top down static camera.

    If game.Touches.Count != 1
    If scene.camera.trackingArea.width != 1280
    If scene.camera.trackingArea.height != 800

    do
    After 0.1 sec (run to completion NOT checked)
    constrain scene.camera.origin.x = 0
    constrain scene.camera.origin.y = 0

  • izamizam Member, PRO Posts: 503

    I haven't tried this. It might work.

    @jagler said:
    Would the rules be this...?

    The idea is to lock the camera to the screen size to the game wont be zoomed/shifted/unplayable. No movable players, just a top down static camera.

    If game.Touches.Count != 1
    If scene.camera.trackingArea.width != 1280
    If scene.camera.trackingArea.height != 800

    do
    After 0.1 sec (run to completion NOT checked)
    constrain scene.camera.origin.x = 0
    constrain scene.camera.origin.y = 0

  • RocketBrainRocketBrain Member, PRO Posts: 269
    edited July 2016

    i can't find the scene.camera.origin.x command in the constrain attributes.

  • UncloudedStudioUncloudedStudio NetherlandsMember Posts: 285

    @RocketBrain You have to place/unlock an actor on the scene to find the command

  • RocketBrainRocketBrain Member, PRO Posts: 269

    well thats not gonna work considering i have many many many scenes.

  • bloodnitebloodnite Member Posts: 50

    @izam said:
    I haven't tried this. It might work.

    @jagler said:
    Would the rules be this...?

    The idea is to lock the camera to the screen size to the game wont be zoomed/shifted/unplayable. No movable players, just a top down static camera.

    snip
    *Added this -> if Any:
    If scene.camera.trackingArea.width != 1280
    If scene.camera.trackingArea.height != 800

    do
    After 0.1 sec (run to completion NOT checked)
    constrain scene.camera.origin.x = 0
    constrain scene.camera.origin.y = 0

    Updated - see above... I've tried it on multiple games and it does the same thing even with that rule... I'm working on cloning my project to set the screen size from 1280x800 to 1280x720, leaving the actors with the rules above on the scenes, and changing it stretch instead of letterbox..

  • bloodnitebloodnite Member Posts: 50

    Feel free to test etc too... this is driving me crazy!!!

  • RocketBrainRocketBrain Member, PRO Posts: 269

    anybody have any solutions that'll work across multiple scenes? i tried putting in an actor that had camera control that would spawn where i wanted the camera and it kinda worked but ended up causing other problems lol

  • RocketBrainRocketBrain Member, PRO Posts: 269

    sigh now i messed up my game. its starting the camera way to the top right of where its supposed to be and i can't undo (forgot to save a different version smh)

  • NNterprisesNNterprises Member, PRO Posts: 387

    @RocketBrain it may be annoying but cant you put an instance of the actor on every scene and make sure its the correct location on all of them?

  • freneticzfreneticz SwedenMember, PRO Posts: 774

    The misaligned bug is not good at all , and if you make it sleep and Wake again it move even more out of position....... not good at all if you want to look like a serious developer

  • RocketBrainRocketBrain Member, PRO Posts: 269

    hmmm got it to work sort of except it made my landscape game go portrait and squishy.

  • freneticzfreneticz SwedenMember, PRO Posts: 774
    edited August 2016

    What did you try? @RocketBrain I have test many things with no luck :(
    Will this be fixed in next release @ForumNinja @uptimistik @adent42

  • izamizam Member, PRO Posts: 503
    edited November 2016

    I guess my workaround failed. I found that if I made my scene size bigger than the regular sized display of iPhone or iPad or other devices, then my workaround does not work.
    No matter how I try to constrain the camera X and camera Y, it will alway misalign.

    check this out.


    This had been one of the reasons why Google Play will not feature my games anymore. Beyond me. I really can't do anything about it. Tough.

  • BigDaveBigDave Member Posts: 2,239

    beautiful, is there a bug ticket? Does someone care? Maybe hiring another coder instead of sales people could help?
    @ForumNinja

  • ZwireZwire Member, PRO Posts: 182

    They still havent fixed this bug.

    Im almost done with my game but I cant and wont publish my game with this annoying bug. It looks so amateurish. If people will see this bug im sure they will give negative reviews.

  • freneticzfreneticz SwedenMember, PRO Posts: 774
  • JapsterJapster Member Posts: 672
    edited April 2017

    un-freaking-believable...

    ...and this is why I figure, **** it, I'll be moving - I want to publish to Steam anyway - mobile market seems to be saturated / 99 out of 100 games just can't get visibility, but still would have published to all markets, including mobile - but STILL this? - nahh... forget it.

  • DigiChainDigiChain Member, PRO Posts: 1,288

    I don't seem to have this issue as my games don't actually go into sleep mode (at least not on my test device)...

    I wonder - does having a timer in your scene that changes an attribute Every X seconds prevent sleep mode? If so this may be why my games aren't sleeping, and therefore a temporary solution until GS get their act together.

  • JapsterJapster Member Posts: 672
    edited April 2017

    May be worth trying @DigiChain, but doesn't it also happen if the game loses focus? - call taken, other app loads afterwards, etc?

    I think this is why it's so frustrating - it's on a mobile device, which means that the game can be interrupted by a myriad of things, calls and texts just being a couple of them, even say, locking it and putting it in your pocket when you get on a bus etc, to resume in a few minutes, so this issue can potentially happen VERY often, even if care is taken to stop the phone from sleeping in the meantime - meaning a very poor impression is given, bad reviews, and uninstalls will also happen in some (maybe many) cases... :frowning:

  • IceboxIcebox Member Posts: 1,485

    i dont think they will look into the bug right now , or any other bug .. they are putting all their time to develop the the web version of gs and fixing html5 engine . there are major bugs that they know about but im sure it will take time until they look into them .. misaligned bug , loading screen and phone call bug. We might just wait until the web version is live. The good thing they will add more features and fix bugs much quicker after its done + the html engine will be good to match gs viewer so everything will be better hopefully.

  • DigiChainDigiChain Member, PRO Posts: 1,288

    @Japster - i'm testing on a Nexus 7 tablet so not sure what effect phone calls have, however I've just minimised the game and opened a new app then gone back to it and all is fine. I've also locked the device whilst running the app, it's still running/aligned as it should be when unlocking again.

    I've not tested on any other android devices so don't know if that makes a difference - but I've published numerous apps over the past year to android and aren't aware of bad reviews due to this issue... yet!

  • birdboybirdboy Member Posts: 284
    edited April 2017

    @DigiChain
    So you think this might be the case because of an Every Timer changing an attribute? I'll check this out, back in a minute.

    edit/ But it doesn't make to much sense to me because these timers don't continue ticking while the app isn't focused, do they?

  • pHghostpHghost London, UKMember Posts: 2,342

    @DigiChain What Android version do you have on that device. I tested it on an Android 4 device and no problems. I think this is related to newer Android versions/devices.

  • DigiChainDigiChain Member, PRO Posts: 1,288

    @Hoodloc - I'm not sure why I'm not seeing the issue, I wasn't aware of it until reading this thread... and I do have a tendancy to use timers so that may be the reason.

    @pHghost - It's running Android version 6.0.1

  • SocksSocks London, UK.Member Posts: 12,822

    @Icebox said:
    The good thing they will add more features and fix bugs much quicker after its done . . .

    We've been hearing that for years, I really hope it's true this time, but the sensible part of me takes it all with a grain of salt.

  • birdboybirdboy Member Posts: 284
    edited April 2017

    It's so hard to get hold of this bug and for some reason it's different on different devices (maybe processing power has an influence on the outcome). I've put an Every 0.2s Timer in my game but nothing has changed - there's still a slight stutter where the game window jumps ~80 pixels down and back when it regains focus after minimizing it.

    But you're right, I don't see any hickups in Escape That Level. Right now I have no idea why, this is such a strange bug.

Sign In or Register to comment.