Sean Gilhuly | 150ecbf7 | 2021-02-24 22:23:50 | [diff] [blame] | 1 | ## GPU Process Fallback |
| 2 | |
| 3 | When the GPU process crashes repeatedly, usually 3 crashes in a short timeframe, |
| 4 | a less desirable but hopefully more stable mode will be chosen for the next |
| 5 | startup. Where available, we want to use Vulkan over GL, and GL over software. |
| 6 | Vulkan is more experimental than GL and doesn't have the same level of support |
| 7 | or maturity. Software rendering should be more stable than accelerated graphics |
| 8 | because it doesn't rely on third party drivers, or on graphics hardware outside |
| 9 | our control. |
| 10 | |
| 11 | |
| 12 | ### Crash Counting |
| 13 | |
| 14 | GPU process crashes are counted in `GpuProcessHost::RecordProcessCrash()`. |
| 15 | Occasional crashes are permitted without triggering the fallback behaviour, |
| 16 | so one crash is forgiven per interval elapsed since the last crash. For example, |
| 17 | if the GPU crashes for a second time after N minutes, the previous crash is |
| 18 | forgiven. This interval is determined by `GetForgiveMinutes()`. If the crash |
| 19 | limit is hit, then fallback occurs. |
| 20 | |
| 21 | The crash limit, determined by `kGpuFallbackCrashCount`, is higher on Android |
| 22 | and ChromeOS because these platforms don't support software rendering. |
| 23 | Additionally, on Android, the OS can kill the GPU process arbitrarily. So the |
| 24 | crash tolerance is a little bit wider here. |
| 25 | |
| 26 | |
| 27 | ### Fallback Order |
| 28 | |
| 29 | The order of GPU process modes is determined at startup based on the platform, |
| 30 | command line switches, and enabled features. This is then stored as a stack in |
| 31 | `GpuDataManagerImplPrivate::fallback_modes_`. |
| 32 | |
| 33 | For example, on Linux with all options available, the stack of GPU modes will |
| 34 | look like this after initialization: |
| 35 | |
| 36 | +--------------------+ |
| 37 | | HARDWARE_VULKAN | <-- |
| 38 | +--------------------+ |
| 39 | | HARDWARE_GL | |
| 40 | +--------------------+ |
| 41 | | SWIFTSHADER | |
| 42 | +--------------------+ |
| 43 | | DISPLAY_COMPOSITOR | |
| 44 | +--------------------+ |
| 45 | |
| 46 | After the order is determined, or when fallback occurs, the top element from the |
| 47 | stack is popped and used as the next GPU mode. If the stack is empty when |
| 48 | fallback occurs, then the GPU process is too unstable to use, and the Browser |
| 49 | process intentionally crashes. |
| 50 | |
| 51 | |
| 52 | ### GPU Modes |
| 53 | |
| 54 | |
| 55 | #### `HARDWARE_GL` |
| 56 | |
| 57 | The GPU process is running with OpenGL hardware acceleration enabled. |
| 58 | |
| 59 | |
| 60 | #### `HARDWARE_METAL` and `HARDWARE_VULKAN` |
| 61 | |
| 62 | The GPU process is running with OpenGL hardware acceleration enabled, as well as |
| 63 | Metal or Vulkan. |
| 64 | |
| 65 | This doesn't necessarily determine what Metal or Vulkan are being used for, just |
| 66 | that they are initialized. In particular, for Vulkan, `--enable-features=Vulkan` |
| 67 | will cause Vulkan to be used for compositing and rasterization, whereas |
| 68 | `--use-vulkan` by itself will only initialize Vulkan so that it can be used for |
| 69 | other purposes, such as WebGPU. |
| 70 | |
| 71 | |
| 72 | #### `SWIFTSHADER` |
| 73 | |
| 74 | The GPU process is running with hardware acceleration disabled, but SwiftShader |
| 75 | will be initialized for software-backed WebGL. |
| 76 | |
| 77 | |
| 78 | #### `DISPLAY_COMPOSITOR` |
| 79 | |
| 80 | The GPU process is running for the display compositor only, no acceleration is |
| 81 | enabled. |
| 82 | |
| 83 | |
Sean Gilhuly | 150ecbf7 | 2021-02-24 22:23:50 | [diff] [blame] | 84 | ### Special Cases |
| 85 | |
| 86 | There are a few platforms that expect hardware acceleration, with some |
| 87 | exceptions for certain circumstances. |
| 88 | |
| 89 | |
| 90 | #### Android Chromecast Audio-Only |
| 91 | |
| 92 | Android requires hardware acceleration, except in the case of Chromecast |
| 93 | audio-only builds. These run with the flag `--disable-gpu`, and the GPU process |
Zhenyao Mo | 4af7d3fb | 2021-04-29 21:08:02 | [diff] [blame] | 94 | is launched in `DISPLAY_COMPOSITOR` mode. |
Sean Gilhuly | 150ecbf7 | 2021-02-24 22:23:50 | [diff] [blame] | 95 | |
| 96 | |
| 97 | #### Fuchsia |
| 98 | |
| 99 | Fuchsia always expects Vulkan to be available, and doesn't support falling back |
| 100 | to using GL or software. For testing purposes, the flag `--disable-gpu` is |
| 101 | allowed, and the GPU process will be launched in `SWIFTSHADER` mode. |