optimus-manager icon indicating copy to clipboard operation
optimus-manager copied to clipboard

Optimus manager can't start propely with something wrong of decoding state.json

Open h4kuy4 opened this issue 3 years ago • 3 comments

Describe the bug When I start optimus manager, python showed that there is something wrong while decoding a json file, a opened that json file(/var/lib/optimus-manager/tmp/state.json), and find it is a empty file. I rebuild the optimus manager, it still is a empty file.

System info Please include :

  • Archlinux
  • i3wm
  • optimus-managerversion 1.4

Logs

[hakuya@Shigure:~]$ optimus-manager                                     (07-05 03:37)
Traceback (most recent call last):
  File "/usr/bin/optimus-manager", line 33, in <module>
    sys.exit(load_entry_point('optimus-manager==1.4', 'console_scripts', 'optimus-manager')())
  File "/usr/lib/python3.9/site-packages/optimus_manager/client/__init__.py", line 23, in main
    state = load_state()
  File "/usr/lib/python3.9/site-packages/optimus_manager/var.py", line 140, in load_state
    return json.load(f)
  File "/usr/lib/python3.9/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

h4kuy4 avatar Jul 04 '21 11:07 h4kuy4

You've got this behavior because optimus-manager did not launch correcty (just installed). Check daemon status systemctl status optimus-manager.service and then reboot. If you will have problems check FAQ. After correct boot content of .json will be like this

{"type": "done", "switch_id": "20210724T003120", "current_mode": "integrated"}

superpupervlad avatar Jul 23 '21 21:07 superpupervlad

Getting the same error message, optimus-manager seems to have started and running just fine.

● optimus-manager.service - Optimus Manager Commands Daemon
     Loaded: loaded (/usr/lib/systemd/system/optimus-manager.service; enabled; vendor preset: disabled)
     Active: active (running) since Sun 2021-08-08 18:20:03 AEST; 5min ago
    Process: 440 ExecStartPre=/usr/bin/python3 -u -m optimus_manager.hooks.pre_daemon_start (code=exited, status=0/SUCCESS)
    Process: 524 ExecStartPre=/usr/bin/python3 -u -m optimus_manager.hooks.pre_xorg_start (code=exited, status=0/SUCCESS)
   Main PID: 582 (python3)
      Tasks: 1 (limit: 18759)
     Memory: 42.0M
        CPU: 1.356s
     CGroup: /system.slice/optimus-manager.service
             └─582 /usr/bin/python3 -u -m optimus_manager.daemon

Aug 08 18:20:03 graviton python3[524]: [1138] INFO: Setting GPU power to OFF via bbswitch
Aug 08 18:20:03 graviton python3[524]: [1213] INFO: Loaded extra Intel Xorg options (0 lines)
Aug 08 18:20:03 graviton python3[524]: [1213] INFO: Loaded extra Intel Xorg options (0 lines)
Aug 08 18:20:03 graviton python3[524]: [1214] INFO: Writing to /etc/X11/xorg.conf.d/10-optimus-manager.conf
Aug 08 18:20:03 graviton python3[524]: [1214] INFO: Writing state {'type': 'pending_post_xorg_start', 'switch_id': '20210808T182002', 'requested_mode': 'intel'}
Aug 08 18:20:03 graviton python3[524]: [1215] INFO: Xorg pre-start hook completed successfully.
Aug 08 18:20:03 graviton systemd[1]: Started Optimus Manager Commands Daemon.
Aug 08 18:20:03 graviton python3[582]: [1] INFO: # Commands daemon
Aug 08 18:20:03 graviton python3[582]: [1] INFO: Opening UNIX socket
Aug 08 18:20:03 graviton python3[582]: [1] INFO: Awaiting commands

Happened to me after a sudden shutdown, and am also using the exact same setup (i3/arch) not sure if related.

nickfarrow avatar Aug 08 '21 08:08 nickfarrow

Looks like my /var/lib/optimus-manager/tmp/state.json is empty (from envs.STATE_FILE_PATH L139).

Temporary solution: Delete /var/lib/optimus-manager/tmp/state.json Restart with sudo systemctl restart optimus-manager.service Run prime-offload (maybe u don't need to?) Now switching works for me. Probably will break again after a restart, some deeper problem here.

nickfarrow avatar Aug 08 '21 08:08 nickfarrow

Sup @nickfarrow @h4kuy4 . Is this issue still relevant? Are you still facing this with optimus-manager-git ?

Since the last update on this case was from 3 years ago, we'll keep this case opened for some days and close it if no answer is provided.

Have a nice week ahead.

nwildner avatar Jul 01 '24 10:07 nwildner