Browser On Suspend/On Resume not triggering

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the Construct Starter Kit Collection and the Student Workbook from the Workshop.
  • Problem Description

    Browser>On Suspend & Browser>On Resume not triggering on Chrome for iOS and Android stock browser.

    Attach a Capx ... sp=sharing

    Description of Capx

    A blue sprite and a orange sprite show up when you load the layout, when the browser is suspended(minimized to background) and Browser>On Suspended is triggered, the blue sprite changes to green, and when Browser>On Resume is triggered the orange sprite changes to pink when the game is is the foreground again.

    Steps to Reproduce Bug

    • Open the game in Chrome for iOS or the stock Android browser
    • Minimize the game to the background by pressing the home button on either iOS or Android
    • Reopen the browser to the foreground

    Observed Result

    When the browser is minimized to the background then reopened the blue sprite does not change to green because Browser>On Suspend was not triggered and the orange sprite does not change to pink because Browser>On Resume was not triggered.

    Expected Result

    The blue sprite should change to green when Browser>On Suspend is triggered, the orange sprite should change to pink when Browser>On Resume is triggered.

    Affected Browsers

    • Chrome for iOS (YES)
    • Stock Android Browser for Android 5.0 (YES)
    • Internet Explorer: (NO)
    • Firefox: (NO)
    • Firefox Android: (NO)
    • Chrome for Android: (NO)
    • Chrome for PC: (NO)
    • Safari for iOS: (NO)
    • Safari for Mac: (NO)

    Operating System and Service Pack

    Windows 7 Home Premium, Service Pack 1

    Construct 2 Version ID


    Notes: I noticed this bug when testing a game on Chrome for iOS and the stock Android browser, when you minimize the browser to the background your background music keeps playing, but on Safari for iOS and Chrome for Android it stops playing the music till the browser gains focus again. Not sure if this is on the C2 side or on the browser side.

  • Closing as won't fix: the problem is with the browser, not C2.

    In Chrome for iOS, it correctly triggers 'On suspend' and 'On resume' when switching tabs, but not when returning to the home screen and going back (which Safari does correctly). Old Android stock browsers simply don't support the Page Visibility API which is the way the browser tells C2 if the page has been hidden, so it can't be supported. It should work in Chrome for Android though.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Are there any methods I could call from Javascript manually, to inform construct about the visibility change?

  • Are there any methods I could call from Javascript manually, to inform construct about the visibility change?

    I found it out myself. Use this code to trigger the supend and resume manually:

    function simulatePageVisibilityApiHide() {
        document.hidden = true;
        document.mozHidden = true;
        document.webkitHidden = true;
        document.msHidden = true;
        var event = new Event('visibilitychange');
    function simulatePageVisibilityApiUnhide() {
        document.hidden = false;
        document.mozHidden = false;
        document.webkitHidden = false;
        document.msHidden = false;
        var event = new Event('visibilitychange');
  • Waog Where do I put this code. Is it in the index file?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)