---
# System prepended metadata

title: 'display::Screen initialization'
tags: [Chromium-Graphics, elkurin-daily-note]

---

# display::Screen initialization in ChromeOS
[display::Screen](https://source.chromium.org/chromium/chromium/src/+/main:ui/display/screen.h;l=44;drc=0f6147b0bd5c08d94de0905eaa40cfae8853c346) is a utility class to handle screen information such as size, displayds, cursor position and so on.

When is this created?  
This note aims to check the timing for each lacros and ash platform, and compare them.

## On Ash
On ash, display::Screen is [ScreenAsh](https://source.chromium.org/chromium/chromium/src/+/main:ash/display/screen_ash.h;l=27;drc=b86c8e20c6a0952e10c7b80929e777f77c094a8d).  

This is created by [CreateDisplayManager](https://source.chromium.org/chromium/chromium/src/+/main:ash/display/screen_ash.cc;l=220;drc=42f0b9c4f60f67676d9096b3e94df9fd47f568f4) together with [DisplayManager](https://source.chromium.org/chromium/chromium/src/+/main:ui/display/manager/display_manager.h;l=59;drc=42f0b9c4f60f67676d9096b3e94df9fd47f568f4) as a member of ash::Shell.  
ash::Shell is initialized by [ChromeBrowserMainExtraPartsAsh::PreProfileInit](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/ash/chrome_browser_main_extra_parts_ash.cc;l=203;drc=42f0b9c4f60f67676d9096b3e94df9fd47f568f4), so the screen is also initialized inside PreProfileInit.  
Screen is guaranteed to exist when profile is initialized and ready.

## On Lacros
For Lacros, display::Screen is [DesktopScreenOzone](https://source.chromium.org/chromium/chromium/src/+/main:ui/views/widget/desktop_aura/desktop_screen_ozone.h;l=13;drc=3e1a26c44c024d97dc9a4c09bbc6a2365398ca2c).  
This has a platform screen which is [WaylandScreen](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_screen.h;l=40;drc=712c29d148926490185747d63ab4d742190137d4), but this is not display::Screen itself in ui.  
This initialized at [ChromeBrowserMainExtraPartsView::PreCreateThreads](https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc;l=112;drc=d78ab264fc6d9d013047f9d7bf1beafb00c02ebd).  
PreCreateThreads is called inside [BrowserMainLoop::CreateThreads](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/browser_main_loop.cc;l=879;drc=42f0b9c4f60f67676d9096b3e94df9fd47f568f4) while PreProfileInit is inside [BrowserMainLoop::PreMainMessageLoopRun](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/browser_main_loop.cc;l=891;drc=42f0b9c4f60f67676d9096b3e94df9fd47f568f4).  
Both of them runs inside [BrowserMainLoop::CreateStartupTasks](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/browser_main_loop.cc;l=860;drc=42f0b9c4f60f67676d9096b3e94df9fd47f568f4) but CreateThreads runs before PreMainMessageLoopRun.

The timing of display::Screen for lacros and ash are slightly different to each other.