Fix #12723 and simplification and optmization of defaultDisplay helper

(cherry picked from commit a25343001eea2436dcf8ea60deea3844f77e42e4)