Subject: Display monitor frames not warmed up

From: Juri Linkov <[email-masked]>
Date: Wed, 27 Feb 2019 23:02:09 +0200

Sometimes desktop restoration fails with the error:

Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
  +(nil nil -1)
  frameset-move-onscreen(#<frame emacs@localhost 0x55a7cd486ed0> t)
  frameset--restore-frame(... t)
  frameset-restore([frameset ...] :reuse-frames t :cleanup-frames t :force-display t :force-onscreen t)
  desktop-restore-frameset()
  desktop-read()
  run-hooks(after-init-hook delayed-warnings-hook)
  command-line()
  normal-top-level()

because ‘frame-monitor-attributes’ in ‘frameset-move-onscreen’ returns ‘nil’.

It returns ‘nil’ because the attribute ‘frames’ returned by
‘display-monitor-attributes-list’ is empty, and ‘frame-monitor-attributes’
filters out the returned attributes if it can't find the arg ‘frame’ in
the list of frames.

However, when ‘display-monitor-attributes-list’ is “warmed up” with just
a ‘message’ call before its first call, its returned ‘frames’ contains
the arg ‘frame’.

I guess calling the function ‘message’ before calling ‘display-monitor-attributes-list’
performs some redisplay that adds the frame to the list of frames in
‘display-monitor-attributes-list’.