Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Reporting: screensaver doesn't work properly #123

Open
hao-lee opened this issue May 2, 2017 · 6 comments
Open

Bug Reporting: screensaver doesn't work properly #123

hao-lee opened this issue May 2, 2017 · 6 comments

Comments

@hao-lee
Copy link
Contributor

hao-lee commented May 2, 2017

Hi,

I found a bug which could be reproduced through the following steps.

NOTE: Regard the computer as idle after is set to 1 minute

  1. Run mate-screensaver-preferences and uncheck "Activate screensaver when computer is idle", then restart the mate-screensaver background process.
  2. Wait 1 minute.
  3. Run mate-screensaver-preferences and check "Activate screensaver when computer is idle".
  4. Wait 1 minute and you will see the screen fades to black but comes back to normal immediately.

Thanks.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@flexiondotorg
Copy link
Member

What version of MATE are you running and on which distro?

@hao-lee
Copy link
Contributor Author

hao-lee commented May 2, 2017

@flexiondotorg
mate-screensaver version: 1.18.0
OS: Ubuntu 17.04

@hao-lee
Copy link
Contributor Author

hao-lee commented May 8, 2017

This problem is very difficult to reproduce, but imagine this scenario: A user enters the desktop with "Activate screensaver when computer is idle" unchecked and check it after several minutes or hours. He will find the screensaver won't be activated as expected no matter how long he idle.

Fortunately, I have found some clues that may result in this problem and I will create a pull request after I fix this problem with a feasible way.

@hao-lee
Copy link
Contributor Author

hao-lee commented May 10, 2017

I have debugged this program for many times and have found that the function _gs_watcher_set_session_idle in gs-watcher-x11.c is the key to solve this problem.
After the first two steps are done as followed, the screensaver process has in an inconsistent state.

NOTE: "Regard the computer as idle after" is set to 1 minute

  1. Run mate-screensaver-preferences and uncheck "Activate screensaver when computer is idle", then restart the mate-screensaver background process.
  2. Wait 1 minute. ("Regard the computer as idle after" is 1 minute)

After these steps, the variable watcher->priv->idle is equals to TRUE, so although the screen is normal, the screensaver thinks our screen has been idle.
Then follow the last two steps.

  1. Run mate-screensaver-preferences and check "Activate screensaver when computer is idle".
  2. Wait 1 minute and you will see the screen fades to black but comes back to normal immediately.

We check that checkbox and wait 1 minute. When the screensaver wants to popup, it finds that watcher->priv->idle is TRUE, so it thinks we have already been idle and won't do anything. Even worse, it will try to activate our screen. That's why the screen fades to black but comes back to normal immediately.

In a short word, when we uncheck that checkbox and wait a minute, watcher->priv->idle is set to TRUE in gs-watcher-x11.c Line 238 though it shouldn't do so.

...
...
...
g_signal_emit (watcher, signals [IDLE_CHANGED], 0, is_idle, &res);
if (res)
{
	gs_debug ("Changing idle state: %d", is_idle);
	watcher->priv->idle = is_idle;  /* Boom! */
}
...
...
...

@zhangxianwei8
Copy link
Contributor

Did you fix this problem yet? @hao-lee

@hao-lee
Copy link
Contributor Author

hao-lee commented Dec 2, 2017

@zhangxianwei8 Not yet. The logic in screensaver is complicated, so I haven't figured out how to change the code. I once tried to do some changes, but this introduced other bugs. For now, the available method to solve this problem is restarting the mate-screensaver background process when it works abnormally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants