Fix two Ozone initialization races.
The first race is only for Ozone DRM. In DrmDisplayHostManager |primary_drm_device_handle_| was being accessed from multiple threads. The value was changed by the IO thread while the OzoneUI thread was still using it. Change calls to GpuThreadObserver OnGpuProcessLaunched() so it happens on the OzoneUI thread. This delays the call slightly but it removes the possibility for a race modifying |primary_drm_device_handle_|. The second race was with OzonePlatform::RegisterStartupCallback(). This is called from the IO thread and it checks if there is an OzonePlatform instance and if Ozone UI initialization has happened. If both of those things are true, then it runs a callback immediately, otherwise it runs a callback after those things become true. The problem is that |g_platform_initialized_ui| was set true on the UI thread before Ozone UI initialization was fully finished. The callback accessed a null OzonePlatform member variable and crashed. Make sure that |g_platform_initialized_ui| is set after initialization is finished and that variable change is protected by the same lock used in RegisterStartupCallback(). The lock only protects changing |g_platform_initialized_ui|, not all of initialization, so the IO thread won't block for an extended period. Bug: 824809, 828407 Change-Id: I73b9404c823c9eeaaeaba99feb1e113953a5bb1b Reviewed-on: https://chromium-review.googlesource.com/980574Reviewed-by:Robert Kroeger <rjkroege@chromium.org> Commit-Queue: kylechar <kylechar@chromium.org> Cr-Commit-Position: refs/heads/master@{#548481}
Showing
Please register or sign in to comment