gfx/ipc/GPUProcessManager.cpp
author Matt Woodrow <mwoodrow@mozilla.com>
Sun, 05 Sep 2021 22:36:45 +0000 (2021-09-05)
changeset 591057 1b49e7328ae43c6565d167f4c391430575097fd3
parent 578765 336664d0f101004ac9b82f8adc1e8a6391639c09
child 596032 9c05a84a1059c57a8c003f414ca2c5966d7380e1
permissions -rw-r--r--
Bug 1727682 - Make WebRenderLayerManager not inherit LayerManager. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D124433
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
305336
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
     1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
389027
5f74d262924171a8fa0b4483a64f4cac34c4c9b8 Bug 1412427 part 8: (automated patch) Switch a bunch of C++ files in gfx to use our standard mode lines. r=jrmuizel
Daniel Holbert <dholbert@cs.stanford.edu>
parents: 388632
diff changeset
     2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
298484
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
     3
/* This Source Code Form is subject to the terms of the Mozilla Public
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
     4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
     5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
342859
b35fd9bd12a5d3d63cb7bd02453e5e270be8a9cf Bug 1339609: Add #include for gfxPrefs.h to all source code that calls gfxPrefs APIs. r=jgilbert
Daniel Holbert <dholbert@cs.stanford.edu>
parents: 342217
diff changeset
     6
298484
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
     7
#include "GPUProcessManager.h"
342859
b35fd9bd12a5d3d63cb7bd02453e5e270be8a9cf Bug 1339609: Add #include for gfxPrefs.h to all source code that calls gfxPrefs APIs. r=jgilbert
Daniel Holbert <dholbert@cs.stanford.edu>
parents: 342217
diff changeset
     8
522159
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
     9
#include "gfxConfig.h"
560188
57c5d3c8466f61f0265fd49adcb2d78aa3ac7e1c Bug 1681563 - Record WebRender device resets in telemetry and crash reports on non-Windows. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 559735
diff changeset
    10
#include "gfxPlatform.h"
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
    11
#include "GPUProcessHost.h"
314602
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
    12
#include "GPUProcessListener.h"
331353
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
    13
#include "mozilla/MemoryReportingProcess.h"
475606
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
    14
#include "mozilla/Preferences.h"
322995
d7f47206d3673701631a9abe73131984ce38b009 Bug 1317757 - Explicitly include header for SprintfLiteral(). r=milan
Jan Beich <jbeich@FreeBSD.org>
parents: 322786
diff changeset
    15
#include "mozilla/Sprintf.h"
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
    16
#include "mozilla/StaticPtr.h"
484792
4e4751677534ad208d37a0630bbcf39cf04de8e9 Bug 1563139 - Remove StaticPrefs.h. r=glandium
Nicholas Nethercote <nnethercote@mozilla.com>
parents: 483647
diff changeset
    17
#include "mozilla/StaticPrefs_gfx.h"
4e4751677534ad208d37a0630bbcf39cf04de8e9 Bug 1563139 - Remove StaticPrefs.h. r=glandium
Nicholas Nethercote <nnethercote@mozilla.com>
parents: 483647
diff changeset
    18
#include "mozilla/StaticPrefs_layers.h"
4e4751677534ad208d37a0630bbcf39cf04de8e9 Bug 1563139 - Remove StaticPrefs.h. r=glandium
Nicholas Nethercote <nnethercote@mozilla.com>
parents: 483647
diff changeset
    19
#include "mozilla/StaticPrefs_media.h"
478151
a1198059b0809f9c752511256aaaec26a2c56a29 Bug 1555891 - Merge PVideoDecoderManager into PRemoteDecoderManager. r=jya,jld
Matt Woodrow <mwoodrow@mozilla.com>
parents: 475617
diff changeset
    20
#include "mozilla/RemoteDecoderManagerChild.h"
a1198059b0809f9c752511256aaaec26a2c56a29 Bug 1555891 - Merge PVideoDecoderManager into PRemoteDecoderManager. r=jya,jld
Matt Woodrow <mwoodrow@mozilla.com>
parents: 475617
diff changeset
    21
#include "mozilla/RemoteDecoderManagerParent.h"
522159
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
    22
#include "mozilla/Telemetry.h"
311190
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
    23
#include "mozilla/dom/ContentParent.h"
372952
901c59d3ab9ff1d54ea365be473bdd254629fbf3 Bug 1354411 - Rebuild CompositorSessions if WebRender is disabled r=kats
sotaro <sotaro.ikeda.g@gmail.com>
parents: 370357
diff changeset
    24
#include "mozilla/gfx/gfxVars.h"
522159
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
    25
#include "mozilla/gfx/GPUChild.h"
558350
267fdd18674019c1c7f579722c8a2c2519c4d24e Bug 1677466 - Split Endpoint.h and ProtocolMessageUtils.h from ProtocolUtils.h. r=mccr8
Simon Giesecke <sgiesecke@mozilla.com>
parents: 557798
diff changeset
    26
#include "mozilla/ipc/Endpoint.h"
311694
81de0e995050eb75595ba97d9ccfee2f96c9ddff Bug 1298245 - Hook up creation of OOP APZ for main process. r=dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311192
diff changeset
    27
#include "mozilla/layers/APZCTreeManagerChild.h"
522159
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
    28
#include "mozilla/layers/APZInputBridgeChild.h"
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
    29
#include "mozilla/layers/CompositorBridgeChild.h"
305339
39636df7a0fe56efe6e0480df7cbb707d18c70b3 Send content compositor bridges using endpoints rather than Opens. (bug 1282348 part 7, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305337
diff changeset
    30
#include "mozilla/layers/CompositorBridgeParent.h"
364055
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
    31
#include "mozilla/layers/CompositorManagerChild.h"
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
    32
#include "mozilla/layers/CompositorManagerParent.h"
329203
3d27c7cbcafa48642e0368319c563c4e32895242 Bug 1330037 - Introduce a CompositorOptions struct that holds options on a per-compositor basis. r=dvander
Kartikaya Gupta <kgupta@mozilla.com>
parents: 322995
diff changeset
    33
#include "mozilla/layers/CompositorOptions.h"
305809
56f707cd8725ee328b9e0d3dd2342a56b2bea119 Move parent-process ImageBridgeChild startup to GPUProcessManager. (bug 1287366 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 305742
diff changeset
    34
#include "mozilla/layers/ImageBridgeChild.h"
305810
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
    35
#include "mozilla/layers/ImageBridgeParent.h"
305336
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
    36
#include "mozilla/layers/InProcessCompositorSession.h"
311190
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
    37
#include "mozilla/layers/LayerTreeOwnerTracker.h"
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
    38
#include "mozilla/layers/RemoteCompositorSession.h"
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
    39
#include "mozilla/widget/PlatformWidgetTypes.h"
417365
bf0dad1ea2c4891fd0f47f3a20c066259ea08bb7 Bug 1366808: Start passing parentBuildID to GPU process to detect buildID mismatches. r=jimm
Stephen A Pohl <spohl.mozilla.bugs@gmail.com>
parents: 413998
diff changeset
    40
#include "nsAppRunner.h"
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
    41
#ifdef MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING
454520
5f4630838d46dd81dadb13220a4af0da9e23a619 Bug 1521000 - Part 2: Adjust our clang-format rules to include spaces after the hash for nested preprocessor directives r=sylvestre
Ehsan Akhgari <ehsan@mozilla.com>
parents: 451773
diff changeset
    42
#  include "mozilla/widget/CompositorWidgetChild.h"
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
    43
#endif
305742
3fdb8ca3e6ffbd310daf342eb8febb1c17938dd0 Implement vsync notification for remote compositors. (bug 1285625 part 3, r=mchang)
David Anderson <danderson@mozilla.com>
parents: 305740
diff changeset
    44
#include "nsBaseWidget.h"
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
    45
#include "nsContentUtils.h"
306036
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
    46
#include "VRManagerChild.h"
306034
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
    47
#include "VRManagerParent.h"
305740
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
    48
#include "VsyncBridgeChild.h"
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
    49
#include "VsyncIOThreadHolder.h"
306673
a9ef44f21177637ddda8d889ae10c79254d6f3de Send vsync rates to the compositor to avoid querying gfxPlatform. (bug 1288822, r=mchang)
David Anderson <danderson@mozilla.com>
parents: 306172
diff changeset
    50
#include "VsyncSource.h"
393528
7d871d84a6a2949233711317587c8ba19965555b Bug 1402519 - Remove MOZ_CRASHREPORTER directives from gfx; r=jrmuizel
Gabriele Svelto <gsvelto@mozilla.com>
parents: 393282
diff changeset
    51
#include "nsExceptionHandler.h"
369587
35beba17c5500c9f0344d40ad90481dc16bc0ac4 Bug 1379813 - Annotate crash reports with the number of times the GPU process has been launched. r=dvander
Dominic Farolino <domfarolino@gmail.com>
parents: 369095
diff changeset
    52
#include "nsPrintfCString.h"
298484
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    53
330452
7ceb7d18b5e090f6283fbe7062bfd194f5863783 Bug 1328752 - part 1, Add UiCompositorController r=dvander
Randall Barker <rbarker@mozilla.com>
parents: 329654
diff changeset
    54
#if defined(MOZ_WIDGET_ANDROID)
454520
5f4630838d46dd81dadb13220a4af0da9e23a619 Bug 1521000 - Part 2: Adjust our clang-format rules to include spaces after the hash for nested preprocessor directives r=sylvestre
Ehsan Akhgari <ehsan@mozilla.com>
parents: 451773
diff changeset
    55
#  include "mozilla/widget/AndroidUiThread.h"
5f4630838d46dd81dadb13220a4af0da9e23a619 Bug 1521000 - Part 2: Adjust our clang-format rules to include spaces after the hash for nested preprocessor directives r=sylvestre
Ehsan Akhgari <ehsan@mozilla.com>
parents: 451773
diff changeset
    56
#  include "mozilla/layers/UiCompositorControllerChild.h"
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    57
#endif  // defined(MOZ_WIDGET_ANDROID)
330452
7ceb7d18b5e090f6283fbe7062bfd194f5863783 Bug 1328752 - part 1, Add UiCompositorController r=dvander
Randall Barker <rbarker@mozilla.com>
parents: 329654
diff changeset
    58
298484
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    59
namespace mozilla {
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    60
namespace gfx {
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    61
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    62
using namespace mozilla::layers;
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    63
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    64
enum class FallbackType : uint32_t {
353245
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
    65
  NONE = 0,
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
    66
  DECODINGDISABLED,
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
    67
  DISABLED,
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
    68
};
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
    69
298484
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    70
static StaticAutoPtr<GPUProcessManager> sSingleton;
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    71
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    72
GPUProcessManager* GPUProcessManager::Get() { return sSingleton; }
298484
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    73
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    74
void GPUProcessManager::Initialize() {
302710
cb97f090f9d42cabffef9812f33da36b316ff88d Synchronize gfxPrefs to the GPU process. (bug 1280822 part 4, r=jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 302632
diff changeset
    75
  MOZ_ASSERT(XRE_IsParentProcess());
298484
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    76
  sSingleton = new GPUProcessManager();
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    77
}
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    78
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    79
void GPUProcessManager::Shutdown() { sSingleton = nullptr; }
298484
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    80
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
    81
GPUProcessManager::GPUProcessManager()
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    82
    : mTaskFactory(this),
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    83
      mNextNamespace(0),
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    84
      mIdNamespace(0),
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    85
      mResourceId(0),
578765
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
    86
      mUnstableProcessAttempts(0),
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
    87
      mTotalProcessAttempts(0),
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    88
      mDeviceResetCount(0),
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    89
      mProcess(nullptr),
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    90
      mProcessToken(0),
578765
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
    91
      mProcessStable(true),
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
    92
      mGPUChild(nullptr) {
316924
01fd505d5cc2621881fa344d977b5054ad055f3b Fix parent process leaks when using the GPU process. (bug 1307972, r=billm)
David Anderson <danderson@mozilla.com>
parents: 316040
diff changeset
    93
  MOZ_COUNT_CTOR(GPUProcessManager);
01fd505d5cc2621881fa344d977b5054ad055f3b Fix parent process leaks when using the GPU process. (bug 1307972, r=billm)
David Anderson <danderson@mozilla.com>
parents: 316040
diff changeset
    94
361247
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
    95
  mIdNamespace = AllocateNamespace();
311190
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
    96
322104
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
    97
  mDeviceResetLastTime = TimeStamp::Now();
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
    98
311190
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
    99
  LayerTreeOwnerTracker::Initialize();
510386
15fbe779dd3015b318505c5f42cad4127bfac3ad Bug 1609268 - Make WebRender debug prefs apply live without the GPU process. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 509764
diff changeset
   100
  CompositorBridgeParent::InitializeStatics();
298484
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
   101
}
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
   102
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   103
GPUProcessManager::~GPUProcessManager() {
316924
01fd505d5cc2621881fa344d977b5054ad055f3b Fix parent process leaks when using the GPU process. (bug 1307972, r=billm)
David Anderson <danderson@mozilla.com>
parents: 316040
diff changeset
   104
  MOZ_COUNT_DTOR(GPUProcessManager);
01fd505d5cc2621881fa344d977b5054ad055f3b Fix parent process leaks when using the GPU process. (bug 1307972, r=billm)
David Anderson <danderson@mozilla.com>
parents: 316040
diff changeset
   105
311190
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
   106
  LayerTreeOwnerTracker::Shutdown();
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
   107
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   108
  // The GPU process should have already been shut down.
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   109
  MOZ_ASSERT(!mProcess && !mGPUChild);
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   110
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   111
  // We should have already removed observers.
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   112
  MOZ_ASSERT(!mObserver);
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   113
}
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   114
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   115
NS_IMPL_ISUPPORTS(GPUProcessManager::Observer, nsIObserver);
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   116
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   117
GPUProcessManager::Observer::Observer(GPUProcessManager* aManager)
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   118
    : mManager(aManager) {}
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   119
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   120
NS_IMETHODIMP
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   121
GPUProcessManager::Observer::Observe(nsISupports* aSubject, const char* aTopic,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   122
                                     const char16_t* aData) {
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   123
  if (!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   124
    mManager->OnXPCOMShutdown();
475606
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   125
  } else if (!strcmp(aTopic, "nsPref:changed")) {
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   126
    mManager->OnPreferenceChange(aData);
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   127
  }
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   128
  return NS_OK;
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   129
}
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   130
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   131
void GPUProcessManager::OnXPCOMShutdown() {
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   132
  if (mObserver) {
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   133
    nsContentUtils::UnregisterShutdownObserver(mObserver);
475606
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   134
    Preferences::RemoveObserver(mObserver, "");
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   135
    mObserver = nullptr;
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   136
  }
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   137
305740
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   138
  CleanShutdown();
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   139
}
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   140
475606
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   141
void GPUProcessManager::OnPreferenceChange(const char16_t* aData) {
536944
14ea312ed2ce124f37e67c301cac224d18527015 Bug 1647795 - Remove some uses of "blacklist" from dom/ipc/. r=nika
Andrew McCreight <continuation@gmail.com>
parents: 522159
diff changeset
   142
  // A pref changed. If it is useful to do so, inform child processes.
475606
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   143
  if (!dom::ContentParent::ShouldSyncPreference(aData)) {
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   144
    return;
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   145
  }
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   146
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   147
  // We know prefs are ASCII here.
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   148
  NS_LossyConvertUTF16toASCII strData(aData);
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   149
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   150
  mozilla::dom::Pref pref(strData, /* isLocked */ false, Nothing(), Nothing());
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   151
  Preferences::GetPreference(&pref);
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   152
  if (!!mGPUChild) {
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   153
    MOZ_ASSERT(mQueuedPrefs.IsEmpty());
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   154
    mGPUChild->SendPreferenceUpdate(pref);
514406
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   155
  } else if (IsGPUProcessLaunching()) {
475606
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   156
    mQueuedPrefs.AppendElement(pref);
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   157
  }
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   158
}
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   159
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   160
void GPUProcessManager::LaunchGPUProcess() {
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   161
  if (mProcess) {
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   162
    return;
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   163
  }
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   164
514406
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   165
  // Start listening for pref changes so we can
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   166
  // forward them to the process once it is running.
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   167
  if (!mObserver) {
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   168
    mObserver = new Observer(this);
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   169
    nsContentUtils::RegisterShutdownObserver(mObserver);
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   170
    Preferences::AddStrongObserver(mObserver, "");
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   171
  }
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   172
305740
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   173
  // Start the Vsync I/O thread so can use it as soon as the process launches.
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   174
  EnsureVsyncIOThread();
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   175
578765
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   176
  // If the process didn't live long enough, reset the stable flag so that we
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   177
  // don't end up in a restart loop.
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   178
  auto newTime = TimeStamp::Now();
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   179
  if (mTotalProcessAttempts > 0) {
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   180
    auto delta = (int32_t)(newTime - mProcessAttemptLastTime).ToMilliseconds();
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   181
    if (delta < StaticPrefs::layers_gpu_process_stable_min_uptime_ms()) {
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   182
      mProcessStable = false;
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   183
    }
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   184
  }
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   185
  mProcessAttemptLastTime = newTime;
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   186
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   187
  if (!mProcessStable) {
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   188
    mUnstableProcessAttempts++;
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   189
  }
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   190
  mTotalProcessAttempts++;
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   191
  mProcessStable = false;
316040
0d3ad9d3943ab9360eb4df8f0615a34e7e32ae76 Add a testing pref to let the GPU process restart multiple times. (bug 1305941, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 315663
diff changeset
   192
417365
bf0dad1ea2c4891fd0f47f3a20c066259ea08bb7 Bug 1366808: Start passing parentBuildID to GPU process to detect buildID mismatches. r=jimm
Stephen A Pohl <spohl.mozilla.bugs@gmail.com>
parents: 413998
diff changeset
   193
  std::vector<std::string> extraArgs;
bf0dad1ea2c4891fd0f47f3a20c066259ea08bb7 Bug 1366808: Start passing parentBuildID to GPU process to detect buildID mismatches. r=jimm
Stephen A Pohl <spohl.mozilla.bugs@gmail.com>
parents: 413998
diff changeset
   194
  nsCString parentBuildID(mozilla::PlatformBuildID());
bf0dad1ea2c4891fd0f47f3a20c066259ea08bb7 Bug 1366808: Start passing parentBuildID to GPU process to detect buildID mismatches. r=jimm
Stephen A Pohl <spohl.mozilla.bugs@gmail.com>
parents: 413998
diff changeset
   195
  extraArgs.push_back("-parentBuildID");
bf0dad1ea2c4891fd0f47f3a20c066259ea08bb7 Bug 1366808: Start passing parentBuildID to GPU process to detect buildID mismatches. r=jimm
Stephen A Pohl <spohl.mozilla.bugs@gmail.com>
parents: 413998
diff changeset
   196
  extraArgs.push_back(parentBuildID.get());
bf0dad1ea2c4891fd0f47f3a20c066259ea08bb7 Bug 1366808: Start passing parentBuildID to GPU process to detect buildID mismatches. r=jimm
Stephen A Pohl <spohl.mozilla.bugs@gmail.com>
parents: 413998
diff changeset
   197
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   198
  // The subprocess is launched asynchronously, so we wait for a callback to
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   199
  // acquire the IPDL actor.
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   200
  mProcess = new GPUProcessHost(this);
417365
bf0dad1ea2c4891fd0f47f3a20c066259ea08bb7 Bug 1366808: Start passing parentBuildID to GPU process to detect buildID mismatches. r=jimm
Stephen A Pohl <spohl.mozilla.bugs@gmail.com>
parents: 413998
diff changeset
   201
  if (!mProcess->Launch(extraArgs)) {
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   202
    DisableGPUProcess("Failed to launch GPU process");
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   203
  }
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   204
}
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   205
514406
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   206
bool GPUProcessManager::IsGPUProcessLaunching() {
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   207
  MOZ_ASSERT(NS_IsMainThread());
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   208
  return !!mProcess && !mGPUChild;
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   209
}
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   210
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   211
void GPUProcessManager::DisableGPUProcess(const char* aMessage) {
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   212
  MaybeDisableGPUProcess(aMessage, /* aAllowRestart */ false);
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   213
}
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   214
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   215
bool GPUProcessManager::MaybeDisableGPUProcess(const char* aMessage,
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   216
                                               bool aAllowRestart) {
316040
0d3ad9d3943ab9360eb4df8f0615a34e7e32ae76 Add a testing pref to let the GPU process restart multiple times. (bug 1305941, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 315663
diff changeset
   217
  if (!gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   218
    return true;
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   219
  }
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   220
578585
7b6b315837d97190d677a9397a5d87daa38b9cb9 Bug 1709476 - Allow falling back to Software WebRender from D3D11/WebRender in release. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 575881
diff changeset
   221
  if (!aAllowRestart) {
7b6b315837d97190d677a9397a5d87daa38b9cb9 Bug 1709476 - Allow falling back to Software WebRender from D3D11/WebRender in release. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 575881
diff changeset
   222
    gfxConfig::SetFailed(Feature::GPU_PROCESS, FeatureStatus::Failed, aMessage);
7b6b315837d97190d677a9397a5d87daa38b9cb9 Bug 1709476 - Allow falling back to Software WebRender from D3D11/WebRender in release. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 575881
diff changeset
   223
  }
7b6b315837d97190d677a9397a5d87daa38b9cb9 Bug 1709476 - Allow falling back to Software WebRender from D3D11/WebRender in release. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 575881
diff changeset
   224
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   225
  bool wantRestart = gfxPlatform::FallbackFromAcceleration(
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   226
      FeatureStatus::Unavailable, "GPU Process is disabled",
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   227
      "FEATURE_FAILURE_GPU_PROCESS_DISABLED"_ns);
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   228
  if (aAllowRestart && wantRestart) {
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   229
    // The fallback method can make use of the GPU process.
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   230
    return false;
316040
0d3ad9d3943ab9360eb4df8f0615a34e7e32ae76 Add a testing pref to let the GPU process restart multiple times. (bug 1305941, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 315663
diff changeset
   231
  }
0d3ad9d3943ab9360eb4df8f0615a34e7e32ae76 Add a testing pref to let the GPU process restart multiple times. (bug 1305941, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 315663
diff changeset
   232
578585
7b6b315837d97190d677a9397a5d87daa38b9cb9 Bug 1709476 - Allow falling back to Software WebRender from D3D11/WebRender in release. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 575881
diff changeset
   233
  if (aAllowRestart) {
7b6b315837d97190d677a9397a5d87daa38b9cb9 Bug 1709476 - Allow falling back to Software WebRender from D3D11/WebRender in release. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 575881
diff changeset
   234
    gfxConfig::SetFailed(Feature::GPU_PROCESS, FeatureStatus::Failed, aMessage);
7b6b315837d97190d677a9397a5d87daa38b9cb9 Bug 1709476 - Allow falling back to Software WebRender from D3D11/WebRender in release. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 575881
diff changeset
   235
  }
7b6b315837d97190d677a9397a5d87daa38b9cb9 Bug 1709476 - Allow falling back to Software WebRender from D3D11/WebRender in release. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 575881
diff changeset
   236
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   237
  gfxCriticalNote << aMessage;
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   238
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   239
  gfxPlatform::DisableGPUProcess();
342217
b8a64223f86efbf5725ba740ee7eab952d841b6e Bug 1337487 - Disable WebRender on windows when the GPU process is disabled r=kats
Ryan Hunt <rhunt@eqrion.net>
parents: 341300
diff changeset
   240
353245
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
   241
  Telemetry::Accumulate(Telemetry::GPU_PROCESS_CRASH_FALLBACKS,
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
   242
                        uint32_t(FallbackType::DISABLED));
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
   243
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   244
  DestroyProcess();
305740
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   245
  ShutdownVsyncIOThread();
366622
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   246
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   247
  // We may have been in the middle of guaranteeing our various services are
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   248
  // available when one failed. Some callers may fallback to using the same
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   249
  // process equivalent, and we need to make sure those services are setup
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   250
  // correctly. We cannot re-enter DisableGPUProcess from this call because we
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   251
  // know that it is disabled in the config above.
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   252
  EnsureProtocolsReady();
369982
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   253
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   254
  // If we disable the GPU process during reinitialization after a previous
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   255
  // crash, then we need to tell the content processes again, because they
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   256
  // need to rebind to the UI process.
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   257
  HandleProcessLost();
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   258
  return true;
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   259
}
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   260
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   261
bool GPUProcessManager::EnsureGPUReady() {
320537
c6df219786483e009d46d6fd506924698a5a458f Fix UI process not properly waiting for the GPU process to finish launching. (bug 1314127, r=rhunt)
David Anderson <danderson@mozilla.com>
parents: 318158
diff changeset
   262
  if (mProcess && !mProcess->IsConnected()) {
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   263
    if (!mProcess->WaitForLaunch()) {
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   264
      // If this fails, we should have fired OnProcessLaunchComplete and
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   265
      // removed the process.
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   266
      MOZ_ASSERT(!mProcess && !mGPUChild);
350455
50907f304e247c56192bdd4af58159b4cdab46b8 Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
vincentliu <vliu@mozilla.com>
parents: 348222
diff changeset
   267
      return false;
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   268
    }
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   269
  }
310507
6c00e4ee0d0cda70c0573352e7070130d7ec2767 Communicate GPU process device information across processes. (bug 1294988 part 5, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 310469
diff changeset
   270
401538
ecf18629444aa6514b36dbd137c83ba10f60b66f Bug 1389759 - Fix GPUProcessManager::EnsureGPUReady how did not guarantee the GPU process state is consistent. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 393528
diff changeset
   271
  if (mGPUChild) {
ecf18629444aa6514b36dbd137c83ba10f60b66f Bug 1389759 - Fix GPUProcessManager::EnsureGPUReady how did not guarantee the GPU process state is consistent. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 393528
diff changeset
   272
    if (mGPUChild->EnsureGPUReady()) {
ecf18629444aa6514b36dbd137c83ba10f60b66f Bug 1389759 - Fix GPUProcessManager::EnsureGPUReady how did not guarantee the GPU process state is consistent. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 393528
diff changeset
   273
      return true;
ecf18629444aa6514b36dbd137c83ba10f60b66f Bug 1389759 - Fix GPUProcessManager::EnsureGPUReady how did not guarantee the GPU process state is consistent. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 393528
diff changeset
   274
    }
ecf18629444aa6514b36dbd137c83ba10f60b66f Bug 1389759 - Fix GPUProcessManager::EnsureGPUReady how did not guarantee the GPU process state is consistent. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 393528
diff changeset
   275
ecf18629444aa6514b36dbd137c83ba10f60b66f Bug 1389759 - Fix GPUProcessManager::EnsureGPUReady how did not guarantee the GPU process state is consistent. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 393528
diff changeset
   276
    // If the initialization above fails, we likely have a GPU process teardown
ecf18629444aa6514b36dbd137c83ba10f60b66f Bug 1389759 - Fix GPUProcessManager::EnsureGPUReady how did not guarantee the GPU process state is consistent. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 393528
diff changeset
   277
    // waiting in our message queue (or will soon). We need to ensure we don't
ecf18629444aa6514b36dbd137c83ba10f60b66f Bug 1389759 - Fix GPUProcessManager::EnsureGPUReady how did not guarantee the GPU process state is consistent. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 393528
diff changeset
   278
    // restart it later because if we fail here, our callers assume they should
ecf18629444aa6514b36dbd137c83ba10f60b66f Bug 1389759 - Fix GPUProcessManager::EnsureGPUReady how did not guarantee the GPU process state is consistent. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 393528
diff changeset
   279
    // fall back to a combined UI/GPU process. This also ensures our internal
ecf18629444aa6514b36dbd137c83ba10f60b66f Bug 1389759 - Fix GPUProcessManager::EnsureGPUReady how did not guarantee the GPU process state is consistent. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 393528
diff changeset
   280
    // state is consistent (e.g. process token is reset).
ecf18629444aa6514b36dbd137c83ba10f60b66f Bug 1389759 - Fix GPUProcessManager::EnsureGPUReady how did not guarantee the GPU process state is consistent. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 393528
diff changeset
   281
    DisableGPUProcess("Failed to initialize GPU process");
310507
6c00e4ee0d0cda70c0573352e7070130d7ec2767 Communicate GPU process device information across processes. (bug 1294988 part 5, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 310469
diff changeset
   282
  }
350455
50907f304e247c56192bdd4af58159b4cdab46b8 Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
vincentliu <vliu@mozilla.com>
parents: 348222
diff changeset
   283
50907f304e247c56192bdd4af58159b4cdab46b8 Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
vincentliu <vliu@mozilla.com>
parents: 348222
diff changeset
   284
  return false;
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   285
}
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   286
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   287
void GPUProcessManager::EnsureProtocolsReady() {
366622
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   288
  EnsureCompositorManagerChild();
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   289
  EnsureImageBridgeChild();
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   290
  EnsureVRManager();
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   291
}
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   292
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   293
void GPUProcessManager::EnsureCompositorManagerChild() {
383007
e3e936deef864d23751f7ce71556693a6c79f327 Bug 1389759 - Ensure we tear down CompositorManagerChild correctly if init or the GPU process fail. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 383006
diff changeset
   294
  bool gpuReady = EnsureGPUReady();
e3e936deef864d23751f7ce71556693a6c79f327 Bug 1389759 - Ensure we tear down CompositorManagerChild correctly if init or the GPU process fail. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 383006
diff changeset
   295
  if (CompositorManagerChild::IsInitialized(mProcessToken)) {
364055
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   296
    return;
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   297
  }
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   298
383007
e3e936deef864d23751f7ce71556693a6c79f327 Bug 1389759 - Ensure we tear down CompositorManagerChild correctly if init or the GPU process fail. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 383006
diff changeset
   299
  if (!gpuReady) {
e3e936deef864d23751f7ce71556693a6c79f327 Bug 1389759 - Ensure we tear down CompositorManagerChild correctly if init or the GPU process fail. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 383006
diff changeset
   300
    CompositorManagerChild::InitSameProcess(AllocateNamespace(), mProcessToken);
364055
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   301
    return;
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   302
  }
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   303
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   304
  ipc::Endpoint<PCompositorManagerParent> parentPipe;
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   305
  ipc::Endpoint<PCompositorManagerChild> childPipe;
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   306
  nsresult rv = PCompositorManager::CreateEndpoints(
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   307
      mGPUChild->OtherPid(), base::GetCurrentProcId(), &parentPipe, &childPipe);
364055
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   308
  if (NS_FAILED(rv)) {
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   309
    DisableGPUProcess("Failed to create PCompositorManager endpoints");
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   310
    return;
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   311
  }
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   312
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
   313
  mGPUChild->SendInitCompositorManager(std::move(parentPipe));
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
   314
  CompositorManagerChild::Init(std::move(childPipe), AllocateNamespace(),
383007
e3e936deef864d23751f7ce71556693a6c79f327 Bug 1389759 - Ensure we tear down CompositorManagerChild correctly if init or the GPU process fail. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 383006
diff changeset
   315
                               mProcessToken);
364055
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   316
}
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   317
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   318
void GPUProcessManager::EnsureImageBridgeChild() {
313744
84560a23836b1f4ef01c9f7c63f47ccce1abc285 Remove racy ImageBridgeChild shutdown/creation checks. (bug 1298938 part 4, r=nical)
David Anderson <danderson@mozilla.com>
parents: 313353
diff changeset
   319
  if (ImageBridgeChild::GetSingleton()) {
305811
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   320
    return;
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   321
  }
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   322
350455
50907f304e247c56192bdd4af58159b4cdab46b8 Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
vincentliu <vliu@mozilla.com>
parents: 348222
diff changeset
   323
  if (!EnsureGPUReady()) {
353420
de44ef87432b3ca50dff0fc3c4a76b2d539d1ac8 Bug 1356190 - Fix GetNextExternalImageId() r=jrmuizel
sotaro <sotaro.ikeda.g@gmail.com>
parents: 352068
diff changeset
   324
    ImageBridgeChild::InitSameProcess(AllocateNamespace());
305811
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   325
    return;
305809
56f707cd8725ee328b9e0d3dd2342a56b2bea119 Move parent-process ImageBridgeChild startup to GPUProcessManager. (bug 1287366 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 305742
diff changeset
   326
  }
305811
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   327
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   328
  ipc::Endpoint<PImageBridgeParent> parentPipe;
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   329
  ipc::Endpoint<PImageBridgeChild> childPipe;
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   330
  nsresult rv = PImageBridge::CreateEndpoints(
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   331
      mGPUChild->OtherPid(), base::GetCurrentProcId(), &parentPipe, &childPipe);
305811
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   332
  if (NS_FAILED(rv)) {
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   333
    DisableGPUProcess("Failed to create PImageBridge endpoints");
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   334
    return;
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   335
  }
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   336
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
   337
  mGPUChild->SendInitImageBridge(std::move(parentPipe));
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   338
  ImageBridgeChild::InitWithGPUProcess(std::move(childPipe),
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   339
                                       AllocateNamespace());
305809
56f707cd8725ee328b9e0d3dd2342a56b2bea119 Move parent-process ImageBridgeChild startup to GPUProcessManager. (bug 1287366 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 305742
diff changeset
   340
}
56f707cd8725ee328b9e0d3dd2342a56b2bea119 Move parent-process ImageBridgeChild startup to GPUProcessManager. (bug 1287366 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 305742
diff changeset
   341
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   342
void GPUProcessManager::EnsureVRManager() {
306036
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   343
  if (VRManagerChild::IsCreated()) {
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   344
    return;
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   345
  }
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   346
350455
50907f304e247c56192bdd4af58159b4cdab46b8 Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
vincentliu <vliu@mozilla.com>
parents: 348222
diff changeset
   347
  if (!EnsureGPUReady()) {
306036
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   348
    VRManagerChild::InitSameProcess();
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   349
    return;
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   350
  }
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   351
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   352
  ipc::Endpoint<PVRManagerParent> parentPipe;
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   353
  ipc::Endpoint<PVRManagerChild> childPipe;
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   354
  nsresult rv = PVRManager::CreateEndpoints(
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   355
      mGPUChild->OtherPid(), base::GetCurrentProcId(), &parentPipe, &childPipe);
306036
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   356
  if (NS_FAILED(rv)) {
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   357
    DisableGPUProcess("Failed to create PVRManager endpoints");
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   358
    return;
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   359
  }
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   360
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
   361
  mGPUChild->SendInitVRManager(std::move(parentPipe));
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
   362
  VRManagerChild::InitWithGPUProcess(std::move(childPipe));
306036
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   363
}
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
   364
330452
7ceb7d18b5e090f6283fbe7062bfd194f5863783 Bug 1328752 - part 1, Add UiCompositorController r=dvander
Randall Barker <rbarker@mozilla.com>
parents: 329654
diff changeset
   365
#if defined(MOZ_WIDGET_ANDROID)
354240
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   366
already_AddRefed<UiCompositorControllerChild>
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   367
GPUProcessManager::CreateUiCompositorController(nsBaseWidget* aWidget,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   368
                                                const LayersId aId) {
354240
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   369
  RefPtr<UiCompositorControllerChild> result;
330452
7ceb7d18b5e090f6283fbe7062bfd194f5863783 Bug 1328752 - part 1, Add UiCompositorController r=dvander
Randall Barker <rbarker@mozilla.com>
parents: 329654
diff changeset
   370
350455
50907f304e247c56192bdd4af58159b4cdab46b8 Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
vincentliu <vliu@mozilla.com>
parents: 348222
diff changeset
   371
  if (!EnsureGPUReady()) {
354240
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   372
    result = UiCompositorControllerChild::CreateForSameProcess(aId);
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   373
  } else {
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   374
    ipc::Endpoint<PUiCompositorControllerParent> parentPipe;
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   375
    ipc::Endpoint<PUiCompositorControllerChild> childPipe;
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   376
    nsresult rv = PUiCompositorController::CreateEndpoints(
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   377
        mGPUChild->OtherPid(), base::GetCurrentProcId(), &parentPipe,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   378
        &childPipe);
354240
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   379
    if (NS_FAILED(rv)) {
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   380
      DisableGPUProcess("Failed to create PUiCompositorController endpoints");
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   381
      return nullptr;
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   382
    }
330452
7ceb7d18b5e090f6283fbe7062bfd194f5863783 Bug 1328752 - part 1, Add UiCompositorController r=dvander
Randall Barker <rbarker@mozilla.com>
parents: 329654
diff changeset
   383
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
   384
    mGPUChild->SendInitUiCompositorController(aId, std::move(parentPipe));
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   385
    result = UiCompositorControllerChild::CreateForGPUProcess(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   386
        mProcessToken, std::move(childPipe));
330452
7ceb7d18b5e090f6283fbe7062bfd194f5863783 Bug 1328752 - part 1, Add UiCompositorController r=dvander
Randall Barker <rbarker@mozilla.com>
parents: 329654
diff changeset
   387
  }
354240
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   388
  if (result) {
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   389
    result->SetBaseWidget(aWidget);
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   390
  }
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   391
  return result.forget();
330452
7ceb7d18b5e090f6283fbe7062bfd194f5863783 Bug 1328752 - part 1, Add UiCompositorController r=dvander
Randall Barker <rbarker@mozilla.com>
parents: 329654
diff changeset
   392
}
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   393
#endif  // defined(MOZ_WIDGET_ANDROID)
330452
7ceb7d18b5e090f6283fbe7062bfd194f5863783 Bug 1328752 - part 1, Add UiCompositorController r=dvander
Randall Barker <rbarker@mozilla.com>
parents: 329654
diff changeset
   394
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   395
void GPUProcessManager::OnProcessLaunchComplete(GPUProcessHost* aHost) {
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   396
  MOZ_ASSERT(mProcess && mProcess == aHost);
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   397
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   398
  if (!mProcess->IsConnected()) {
322428
c619e05b026ac56a056a89199319d11cb24eb518 Bug 1316988: Change the wording of the error message. r=rhunt
Milan Sreckovic <milan@mozilla.com>
parents: 322104
diff changeset
   399
    DisableGPUProcess("Failed to connect GPU process");
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   400
    return;
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   401
  }
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   402
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   403
  mGPUChild = mProcess->GetActor();
305336
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   404
  mProcessToken = mProcess->GetProcessToken();
305740
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   405
522159
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
   406
  ipc::Endpoint<PVsyncBridgeParent> vsyncParent;
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
   407
  ipc::Endpoint<PVsyncBridgeChild> vsyncChild;
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   408
  nsresult rv = PVsyncBridge::CreateEndpoints(mGPUChild->OtherPid(),
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   409
                                              base::GetCurrentProcId(),
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   410
                                              &vsyncParent, &vsyncChild);
305740
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   411
  if (NS_FAILED(rv)) {
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   412
    DisableGPUProcess("Failed to create PVsyncBridge endpoints");
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   413
    return;
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   414
  }
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   415
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   416
  mVsyncBridge = VsyncBridgeChild::Create(mVsyncIOThread, mProcessToken,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   417
                                          std::move(vsyncChild));
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
   418
  mGPUChild->SendInitVsyncBridge(std::move(vsyncParent));
350753
7b2da53804c611d5c766ac93aee90fbd6bd3d1ed Backed out 2 changesets (bug 1350660) for causing merge conflicts a=backout
Wes Kocher <wkocher@mozilla.com>
parents: 350752
diff changeset
   419
475606
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   420
  // Flush any pref updates that happened during launch and weren't
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   421
  // included in the blobs set up in LaunchGPUProcess.
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   422
  for (const mozilla::dom::Pref& pref : mQueuedPrefs) {
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   423
    Unused << NS_WARN_IF(!mGPUChild->SendPreferenceUpdate(pref));
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   424
  }
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   425
  mQueuedPrefs.Clear();
e4bea1a40aa96ea76c2d20307937e2bdd3c02315 Bug 1550422 - P4. Sync preferences when they changed. r=mattwoodrow
Jean-Yves Avenard <jyavenard@mozilla.com>
parents: 475564
diff changeset
   426
351066
328c81f2402ca1e235108167a936fd5c4c2881ed Add crash reporter annotations for the GPU process status. (bug 1343650, r=billm)
David Anderson <danderson@mozilla.com>
parents: 350753
diff changeset
   427
  CrashReporter::AnnotateCrashReport(
538158
3f8100fb74318f9e0b3b6351ade737994d13bcf8 Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Simon Giesecke <sgiesecke@mozilla.com>
parents: 536944
diff changeset
   428
      CrashReporter::Annotation::GPUProcessStatus, "Running"_ns);
369587
35beba17c5500c9f0344d40ad90481dc16bc0ac4 Bug 1379813 - Annotate crash reports with the number of times the GPU process has been launched. r=dvander
Dominic Farolino <domfarolino@gmail.com>
parents: 369095
diff changeset
   429
35beba17c5500c9f0344d40ad90481dc16bc0ac4 Bug 1379813 - Annotate crash reports with the number of times the GPU process has been launched. r=dvander
Dominic Farolino <domfarolino@gmail.com>
parents: 369095
diff changeset
   430
  CrashReporter::AnnotateCrashReport(
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   431
      CrashReporter::Annotation::GPUProcessLaunchCount,
578765
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   432
      static_cast<int>(mTotalProcessAttempts));
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   433
}
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   434
578765
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   435
void GPUProcessManager::OnProcessDeclaredStable() { mProcessStable = true; }
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   436
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   437
static bool ShouldLimitDeviceResets(uint32_t count, int32_t deltaMilliseconds) {
322104
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   438
  // We decide to limit by comparing the amount of resets that have happened
364295
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   439
  // and time since the last reset to two prefs.
483647
2cb4ffa920c6ad8a4f9b500222dc41d929114646 Bug 1567329 - Append `_AtStartup` to `once` static pref getters. r=erahm
Nicholas Nethercote <nnethercote@mozilla.com>
parents: 482144
diff changeset
   440
  int32_t timeLimit = StaticPrefs::gfx_device_reset_threshold_ms_AtStartup();
2cb4ffa920c6ad8a4f9b500222dc41d929114646 Bug 1567329 - Append `_AtStartup` to `once` static pref getters. r=erahm
Nicholas Nethercote <nnethercote@mozilla.com>
parents: 482144
diff changeset
   441
  int32_t countLimit = StaticPrefs::gfx_device_reset_limit_AtStartup();
322104
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   442
322786
fe64a3cfb7f03798a474a2e6882ec50333c08714 Bug 1317512 - Prevent overflow when using device reset prefs. r=milan
Ryan Hunt <rhunt@eqrion.net>
parents: 322566
diff changeset
   443
  bool hasTimeLimit = timeLimit >= 0;
fe64a3cfb7f03798a474a2e6882ec50333c08714 Bug 1317512 - Prevent overflow when using device reset prefs. r=milan
Ryan Hunt <rhunt@eqrion.net>
parents: 322566
diff changeset
   444
  bool hasCountLimit = countLimit >= 0;
322104
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   445
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   446
  bool triggeredTime = deltaMilliseconds < timeLimit;
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   447
  bool triggeredCount = count > (uint32_t)countLimit;
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   448
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   449
  // If we have both prefs set then it needs to trigger both limits,
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   450
  // otherwise we only test the pref that is set or none
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   451
  if (hasTimeLimit && hasCountLimit) {
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   452
    return triggeredTime && triggeredCount;
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   453
  } else if (hasTimeLimit) {
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   454
    return triggeredTime;
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   455
  } else if (hasCountLimit) {
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   456
    return triggeredCount;
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   457
  }
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   458
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   459
  return false;
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   460
}
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   461
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   462
void GPUProcessManager::ResetCompositors() {
374693
2dd2794946eb3998f131b6a96fec709c213ede27 Bug 1377950 - Stub in a function for resetting all compositors with GPUProcessManager. r=jrmuizel
Ryan Hunt <rhunt@eqrion.net>
parents: 372952
diff changeset
   463
  // Note: this will recreate devices in addition to recreating compositors.
2dd2794946eb3998f131b6a96fec709c213ede27 Bug 1377950 - Stub in a function for resetting all compositors with GPUProcessManager. r=jrmuizel
Ryan Hunt <rhunt@eqrion.net>
parents: 372952
diff changeset
   464
  // This isn't optimal, but this is only used on linux where acceleration
2dd2794946eb3998f131b6a96fec709c213ede27 Bug 1377950 - Stub in a function for resetting all compositors with GPUProcessManager. r=jrmuizel
Ryan Hunt <rhunt@eqrion.net>
parents: 372952
diff changeset
   465
  // isn't enabled by default, and this way we don't need a new code path.
2dd2794946eb3998f131b6a96fec709c213ede27 Bug 1377950 - Stub in a function for resetting all compositors with GPUProcessManager. r=jrmuizel
Ryan Hunt <rhunt@eqrion.net>
parents: 372952
diff changeset
   466
  SimulateDeviceReset();
2dd2794946eb3998f131b6a96fec709c213ede27 Bug 1377950 - Stub in a function for resetting all compositors with GPUProcessManager. r=jrmuizel
Ryan Hunt <rhunt@eqrion.net>
parents: 372952
diff changeset
   467
}
2dd2794946eb3998f131b6a96fec709c213ede27 Bug 1377950 - Stub in a function for resetting all compositors with GPUProcessManager. r=jrmuizel
Ryan Hunt <rhunt@eqrion.net>
parents: 372952
diff changeset
   468
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   469
void GPUProcessManager::SimulateDeviceReset() {
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   470
  // Make sure we rebuild environment and configuration for accelerated
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   471
  // features.
368211
616baa60cf8747f787c236c24daa516fc1dbfd9b Disable Advanced Layers when the sanity test fails. (bug 1377866 part 3, r=mchang)
David Anderson <danderson@mozilla.com>
parents: 366860
diff changeset
   472
  gfxPlatform::GetPlatform()->CompositorUpdated();
616baa60cf8747f787c236c24daa516fc1dbfd9b Disable Advanced Layers when the sanity test fails. (bug 1377866 part 3, r=mchang)
David Anderson <danderson@mozilla.com>
parents: 366860
diff changeset
   473
364295
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   474
  if (mProcess) {
390137
a5a2ae162869490ca8163c6e483a493ecf6c4c22 Bug 1410766 - Re-acquireDevices in gpu process when SimulateDeviceReset() is called r=dvander
sotaro <sotaro.ikeda.g@gmail.com>
parents: 389027
diff changeset
   475
    GPUDeviceData data;
a5a2ae162869490ca8163c6e483a493ecf6c4c22 Bug 1410766 - Re-acquireDevices in gpu process when SimulateDeviceReset() is called r=dvander
sotaro <sotaro.ikeda.g@gmail.com>
parents: 389027
diff changeset
   476
    if (mGPUChild->SendSimulateDeviceReset(&data)) {
a5a2ae162869490ca8163c6e483a493ecf6c4c22 Bug 1410766 - Re-acquireDevices in gpu process when SimulateDeviceReset() is called r=dvander
sotaro <sotaro.ikeda.g@gmail.com>
parents: 389027
diff changeset
   477
      gfxPlatform::GetPlatform()->ImportGPUDeviceData(data);
a5a2ae162869490ca8163c6e483a493ecf6c4c22 Bug 1410766 - Re-acquireDevices in gpu process when SimulateDeviceReset() is called r=dvander
sotaro <sotaro.ikeda.g@gmail.com>
parents: 389027
diff changeset
   478
    }
364295
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   479
    OnRemoteProcessDeviceReset(mProcess);
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   480
  } else {
559735
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   481
    OnInProcessDeviceReset(/* aTrackThreshold */ false);
364295
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   482
  }
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   483
}
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   484
559735
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   485
bool GPUProcessManager::DisableWebRenderConfig(wr::WebRenderError aError,
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   486
                                               const nsCString& aMsg) {
372952
901c59d3ab9ff1d54ea365be473bdd254629fbf3 Bug 1354411 - Rebuild CompositorSessions if WebRender is disabled r=kats
sotaro <sotaro.ikeda.g@gmail.com>
parents: 370357
diff changeset
   487
  if (!gfx::gfxVars::UseWebRender()) {
559735
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   488
    return false;
372952
901c59d3ab9ff1d54ea365be473bdd254629fbf3 Bug 1354411 - Rebuild CompositorSessions if WebRender is disabled r=kats
sotaro <sotaro.ikeda.g@gmail.com>
parents: 370357
diff changeset
   489
  }
379016
5ca9c4d3658cda11a748e7e8722f3fc51fc80b5d Bug 1390138 - Add render() error handling to gecko. r=jrmuizel
Sotaro Ikeda <sikeda@mozilla.com>
parents: 377666
diff changeset
   490
  // Disable WebRender
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   491
  bool wantRestart;
377666
919487ecd16f41a7e2251130d24e0dc2d959b4ae Bug 1394338 - Add WebRender error handling to RendererOGL r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 374693
diff changeset
   492
  if (aError == wr::WebRenderError::INITIALIZE) {
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   493
    wantRestart = gfxPlatform::FallbackFromAcceleration(
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   494
        gfx::FeatureStatus::Unavailable, "WebRender initialization failed",
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   495
        aMsg);
377666
919487ecd16f41a7e2251130d24e0dc2d959b4ae Bug 1394338 - Add WebRender error handling to RendererOGL r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 374693
diff changeset
   496
  } else if (aError == wr::WebRenderError::MAKE_CURRENT) {
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   497
    wantRestart = gfxPlatform::FallbackFromAcceleration(
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   498
        gfx::FeatureStatus::Unavailable,
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   499
        "Failed to make render context current",
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   500
        "FEATURE_FAILURE_WEBRENDER_MAKE_CURRENT"_ns);
379016
5ca9c4d3658cda11a748e7e8722f3fc51fc80b5d Bug 1390138 - Add render() error handling to gecko. r=jrmuizel
Sotaro Ikeda <sikeda@mozilla.com>
parents: 377666
diff changeset
   501
  } else if (aError == wr::WebRenderError::RENDER) {
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   502
    wantRestart = gfxPlatform::FallbackFromAcceleration(
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   503
        gfx::FeatureStatus::Unavailable, "Failed to render WebRender",
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   504
        "FEATURE_FAILURE_WEBRENDER_RENDER"_ns);
482144
6e35baafea9fdc8ecf978e3ceb595e23d1abb417 Bug 1564720 - Fallback from WebRender when EGLSurface creation failed in RenderCompositorEGL::BeginFrame() r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 481856
diff changeset
   505
  } else if (aError == wr::WebRenderError::NEW_SURFACE) {
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   506
    wantRestart = gfxPlatform::FallbackFromAcceleration(
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   507
        gfx::FeatureStatus::Unavailable, "Failed to create new surface",
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   508
        "FEATURE_FAILURE_WEBRENDER_NEW_SURFACE"_ns);
575881
aaa3b15b32a1d49ba188ebde83ccabf726b9aed6 Bug 1703099 - Separate out BEGIN_DRAW errors from NEW_SURFACE. r=aosmond
Jeff Muizelaar <jmuizelaar@mozilla.com>
parents: 565528
diff changeset
   509
  } else if (aError == wr::WebRenderError::BEGIN_DRAW) {
aaa3b15b32a1d49ba188ebde83ccabf726b9aed6 Bug 1703099 - Separate out BEGIN_DRAW errors from NEW_SURFACE. r=aosmond
Jeff Muizelaar <jmuizelaar@mozilla.com>
parents: 565528
diff changeset
   510
    wantRestart = gfxPlatform::FallbackFromAcceleration(
aaa3b15b32a1d49ba188ebde83ccabf726b9aed6 Bug 1703099 - Separate out BEGIN_DRAW errors from NEW_SURFACE. r=aosmond
Jeff Muizelaar <jmuizelaar@mozilla.com>
parents: 565528
diff changeset
   511
        gfx::FeatureStatus::Unavailable, "BeginDraw() failed",
aaa3b15b32a1d49ba188ebde83ccabf726b9aed6 Bug 1703099 - Separate out BEGIN_DRAW errors from NEW_SURFACE. r=aosmond
Jeff Muizelaar <jmuizelaar@mozilla.com>
parents: 565528
diff changeset
   512
        "FEATURE_FAILURE_WEBRENDER_BEGIN_DRAW"_ns);
559735
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   513
  } else if (aError == wr::WebRenderError::EXCESSIVE_RESETS) {
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   514
    wantRestart = gfxPlatform::FallbackFromAcceleration(
563137
ebc2ea295bd6b2a6fc064af730145e9b8d2b5f2c Bug 1684170 - Decouple WebRender and Software WebRender gfxConfig features. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 561731
diff changeset
   515
        gfx::FeatureStatus::Unavailable, "Device resets exceeded threshold",
ebc2ea295bd6b2a6fc064af730145e9b8d2b5f2c Bug 1684170 - Decouple WebRender and Software WebRender gfxConfig features. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 561731
diff changeset
   516
        "FEATURE_FAILURE_WEBRENDER_EXCESSIVE_RESETS"_ns);
377666
919487ecd16f41a7e2251130d24e0dc2d959b4ae Bug 1394338 - Add WebRender error handling to RendererOGL r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 374693
diff changeset
   517
  } else {
919487ecd16f41a7e2251130d24e0dc2d959b4ae Bug 1394338 - Add WebRender error handling to RendererOGL r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 374693
diff changeset
   518
    MOZ_ASSERT_UNREACHABLE("Invalid value");
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   519
    wantRestart = gfxPlatform::FallbackFromAcceleration(
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   520
        gfx::FeatureStatus::Unavailable, "Unhandled failure reason",
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   521
        "FEATURE_FAILURE_WEBRENDER_UNHANDLED"_ns);
377666
919487ecd16f41a7e2251130d24e0dc2d959b4ae Bug 1394338 - Add WebRender error handling to RendererOGL r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 374693
diff changeset
   522
  }
547943
9c88255c845cf5fd365a6a04b9c13dae145febc3 Bug 1460499 - Use DirectComposition for hardware decoded video on Windows r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 547789
diff changeset
   523
  gfx::gfxVars::SetUseWebRenderDCompVideoOverlayWin(false);
372952
901c59d3ab9ff1d54ea365be473bdd254629fbf3 Bug 1354411 - Rebuild CompositorSessions if WebRender is disabled r=kats
sotaro <sotaro.ikeda.g@gmail.com>
parents: 370357
diff changeset
   524
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   525
  // If we still have the GPU process, and we fallback to a new configuration
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   526
  // that prefers to have the GPU process, reset the counter.
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   527
  if (wantRestart && mProcess) {
578765
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   528
    mUnstableProcessAttempts = 1;
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   529
  }
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   530
479274
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   531
#if defined(MOZ_WIDGET_ANDROID)
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   532
  // If aError is not wr::WebRenderError::INITIALIZE, nsWindow does not
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   533
  // re-create LayerManager. Needs to trigger re-creating LayerManager on
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   534
  // android
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   535
  if (aError != wr::WebRenderError::INITIALIZE) {
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   536
    NotifyDisablingWebRender();
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   537
  }
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   538
#endif
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   539
559735
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   540
  return true;
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   541
}
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   542
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   543
void GPUProcessManager::DisableWebRender(wr::WebRenderError aError,
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   544
                                         const nsCString& aMsg) {
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   545
  if (DisableWebRenderConfig(aError, aMsg)) {
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   546
    if (mProcess) {
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   547
      RebuildRemoteSessions();
559735
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   548
    } else {
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   549
      RebuildInProcessSessions();
559735
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   550
    }
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   551
    NotifyListenersOnCompositeDeviceReset();
372952
901c59d3ab9ff1d54ea365be473bdd254629fbf3 Bug 1354411 - Rebuild CompositorSessions if WebRender is disabled r=kats
sotaro <sotaro.ikeda.g@gmail.com>
parents: 370357
diff changeset
   552
  }
901c59d3ab9ff1d54ea365be473bdd254629fbf3 Bug 1354411 - Rebuild CompositorSessions if WebRender is disabled r=kats
sotaro <sotaro.ikeda.g@gmail.com>
parents: 370357
diff changeset
   553
}
901c59d3ab9ff1d54ea365be473bdd254629fbf3 Bug 1354411 - Rebuild CompositorSessions if WebRender is disabled r=kats
sotaro <sotaro.ikeda.g@gmail.com>
parents: 370357
diff changeset
   554
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   555
void GPUProcessManager::NotifyWebRenderError(wr::WebRenderError aError) {
547943
9c88255c845cf5fd365a6a04b9c13dae145febc3 Bug 1460499 - Use DirectComposition for hardware decoded video on Windows r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 547789
diff changeset
   556
  if (aError == wr::WebRenderError::VIDEO_OVERLAY) {
9c88255c845cf5fd365a6a04b9c13dae145febc3 Bug 1460499 - Use DirectComposition for hardware decoded video on Windows r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 547789
diff changeset
   557
#ifdef XP_WIN
9c88255c845cf5fd365a6a04b9c13dae145febc3 Bug 1460499 - Use DirectComposition for hardware decoded video on Windows r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 547789
diff changeset
   558
    gfxVars::SetUseWebRenderDCompVideoOverlayWin(false);
9c88255c845cf5fd365a6a04b9c13dae145febc3 Bug 1460499 - Use DirectComposition for hardware decoded video on Windows r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 547789
diff changeset
   559
#else
9c88255c845cf5fd365a6a04b9c13dae145febc3 Bug 1460499 - Use DirectComposition for hardware decoded video on Windows r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 547789
diff changeset
   560
    MOZ_ASSERT_UNREACHABLE("unexpected to be called");
9c88255c845cf5fd365a6a04b9c13dae145febc3 Bug 1460499 - Use DirectComposition for hardware decoded video on Windows r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 547789
diff changeset
   561
#endif
9c88255c845cf5fd365a6a04b9c13dae145febc3 Bug 1460499 - Use DirectComposition for hardware decoded video on Windows r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 547789
diff changeset
   562
    return;
9c88255c845cf5fd365a6a04b9c13dae145febc3 Bug 1460499 - Use DirectComposition for hardware decoded video on Windows r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 547789
diff changeset
   563
  }
547789
fe5a386982266a8cd44984bac1dd4565fad0384a Bug 1662836 - Expose detailed initialization failure reason for WebRender. r=kvark
Andrew Osmond <aosmond@mozilla.com>
parents: 538158
diff changeset
   564
  DisableWebRender(aError, nsCString());
377666
919487ecd16f41a7e2251130d24e0dc2d959b4ae Bug 1394338 - Add WebRender error handling to RendererOGL r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 374693
diff changeset
   565
}
919487ecd16f41a7e2251130d24e0dc2d959b4ae Bug 1394338 - Add WebRender error handling to RendererOGL r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 374693
diff changeset
   566
560188
57c5d3c8466f61f0265fd49adcb2d78aa3ac7e1c Bug 1681563 - Record WebRender device resets in telemetry and crash reports on non-Windows. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 559735
diff changeset
   567
/* static */ void GPUProcessManager::RecordDeviceReset(
57c5d3c8466f61f0265fd49adcb2d78aa3ac7e1c Bug 1681563 - Record WebRender device resets in telemetry and crash reports on non-Windows. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 559735
diff changeset
   568
    DeviceResetReason aReason) {
57c5d3c8466f61f0265fd49adcb2d78aa3ac7e1c Bug 1681563 - Record WebRender device resets in telemetry and crash reports on non-Windows. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 559735
diff changeset
   569
  if (aReason != DeviceResetReason::FORCED_RESET) {
57c5d3c8466f61f0265fd49adcb2d78aa3ac7e1c Bug 1681563 - Record WebRender device resets in telemetry and crash reports on non-Windows. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 559735
diff changeset
   570
    Telemetry::Accumulate(Telemetry::DEVICE_RESET_REASON, uint32_t(aReason));
57c5d3c8466f61f0265fd49adcb2d78aa3ac7e1c Bug 1681563 - Record WebRender device resets in telemetry and crash reports on non-Windows. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 559735
diff changeset
   571
  }
57c5d3c8466f61f0265fd49adcb2d78aa3ac7e1c Bug 1681563 - Record WebRender device resets in telemetry and crash reports on non-Windows. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 559735
diff changeset
   572
57c5d3c8466f61f0265fd49adcb2d78aa3ac7e1c Bug 1681563 - Record WebRender device resets in telemetry and crash reports on non-Windows. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 559735
diff changeset
   573
  CrashReporter::AnnotateCrashReport(
57c5d3c8466f61f0265fd49adcb2d78aa3ac7e1c Bug 1681563 - Record WebRender device resets in telemetry and crash reports on non-Windows. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 559735
diff changeset
   574
      CrashReporter::Annotation::DeviceResetReason, int(aReason));
57c5d3c8466f61f0265fd49adcb2d78aa3ac7e1c Bug 1681563 - Record WebRender device resets in telemetry and crash reports on non-Windows. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 559735
diff changeset
   575
}
57c5d3c8466f61f0265fd49adcb2d78aa3ac7e1c Bug 1681563 - Record WebRender device resets in telemetry and crash reports on non-Windows. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 559735
diff changeset
   576
559735
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   577
bool GPUProcessManager::OnDeviceReset(bool aTrackThreshold) {
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   578
#ifdef XP_WIN
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   579
  // Disable double buffering when device reset happens.
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   580
  if (!gfxVars::UseWebRender() && gfxVars::UseDoubleBufferingWithCompositor()) {
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   581
    gfxVars::SetUseDoubleBufferingWithCompositor(false);
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   582
  }
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   583
#endif
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   584
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   585
  // Ignore resets for thresholding if requested.
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   586
  if (!aTrackThreshold) {
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   587
    return false;
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   588
  }
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   589
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   590
  // Detect whether the device is resetting too quickly or too much
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   591
  // indicating that we should give up and use software
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   592
  mDeviceResetCount++;
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   593
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   594
  auto newTime = TimeStamp::Now();
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   595
  auto delta = (int32_t)(newTime - mDeviceResetLastTime).ToMilliseconds();
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   596
  mDeviceResetLastTime = newTime;
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   597
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   598
  // Returns true if we should disable acceleration due to the reset.
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   599
  return ShouldLimitDeviceResets(mDeviceResetCount, delta);
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   600
}
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   601
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   602
void GPUProcessManager::OnInProcessDeviceReset(bool aTrackThreshold) {
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   603
  if (OnDeviceReset(aTrackThreshold)) {
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   604
    gfxCriticalNoteOnce << "In-process device reset threshold exceeded";
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   605
#ifdef MOZ_WIDGET_GTK
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   606
    // FIXME(aosmond): Should we disable WebRender on other platforms?
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   607
    DisableWebRenderConfig(wr::WebRenderError::EXCESSIVE_RESETS, nsCString());
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   608
#endif
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   609
  }
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   610
364295
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   611
  RebuildInProcessSessions();
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   612
  NotifyListenersOnCompositeDeviceReset();
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   613
}
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   614
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   615
void GPUProcessManager::OnRemoteProcessDeviceReset(GPUProcessHost* aHost) {
559735
b98b945b1c0a3975268c15cbd0d4fee225ac9e64 Bug 1632698 - Better handle device resets when we don't have a GPU process. r=sotaro,kvark,nical
Andrew Osmond <aosmond@mozilla.com>
parents: 559096
diff changeset
   616
  if (OnDeviceReset(/* aTrackThreshold */ true)) {
322104
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   617
    DestroyProcess();
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   618
    DisableGPUProcess("GPU processed experienced too many device resets");
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   619
    HandleProcessLost();
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   620
    return;
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   621
  }
358036
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   622
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   623
  RebuildRemoteSessions();
364295
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   624
  NotifyListenersOnCompositeDeviceReset();
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   625
}
322104
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   626
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   627
void GPUProcessManager::NotifyListenersOnCompositeDeviceReset() {
358036
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   628
  for (const auto& listener : mListeners) {
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   629
    listener->OnCompositorDeviceReset();
321756
31fe465d39326229db0d29381b6a088b50fb73df Bug 1313199 - Sync a device reset from GPU process to main process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321614
diff changeset
   630
  }
31fe465d39326229db0d29381b6a088b50fb73df Bug 1313199 - Sync a device reset from GPU process to main process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321614
diff changeset
   631
}
31fe465d39326229db0d29381b6a088b50fb73df Bug 1313199 - Sync a device reset from GPU process to main process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321614
diff changeset
   632
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   633
void GPUProcessManager::OnProcessUnexpectedShutdown(GPUProcessHost* aHost) {
301789
9599664f3e8bbf0d1a15d4332791fcb019d90c9b Implement GPU process shutdown. (bug 1271180 part 5, r=billm)
David Anderson <danderson@mozilla.com>
parents: 301788
diff changeset
   634
  MOZ_ASSERT(mProcess && mProcess == aHost);
9599664f3e8bbf0d1a15d4332791fcb019d90c9b Implement GPU process shutdown. (bug 1271180 part 5, r=billm)
David Anderson <danderson@mozilla.com>
parents: 301788
diff changeset
   635
553255
6db3be2917972ba0da2161743af97c82fbd1ff1c Bug 1654477 P4: Add pref to crash the browser if the GPU process crashes for testing. r=jrmuizel
Bob Owen <bobowencode@gmail.com>
parents: 550988
diff changeset
   636
  if (StaticPrefs::layers_gpu_process_crash_also_crashes_browser()) {
6db3be2917972ba0da2161743af97c82fbd1ff1c Bug 1654477 P4: Add pref to crash the browser if the GPU process crashes for testing. r=jrmuizel
Bob Owen <bobowencode@gmail.com>
parents: 550988
diff changeset
   637
    MOZ_CRASH("GPU process crashed and pref is set to crash the browser.");
6db3be2917972ba0da2161743af97c82fbd1ff1c Bug 1654477 P4: Add pref to crash the browser if the GPU process crashes for testing. r=jrmuizel
Bob Owen <bobowencode@gmail.com>
parents: 550988
diff changeset
   638
  }
6db3be2917972ba0da2161743af97c82fbd1ff1c Bug 1654477 P4: Add pref to crash the browser if the GPU process crashes for testing. r=jrmuizel
Bob Owen <bobowencode@gmail.com>
parents: 550988
diff changeset
   639
383007
e3e936deef864d23751f7ce71556693a6c79f327 Bug 1389759 - Ensure we tear down CompositorManagerChild correctly if init or the GPU process fail. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 383006
diff changeset
   640
  CompositorManagerChild::OnGPUProcessLost(aHost->GetProcessToken());
301789
9599664f3e8bbf0d1a15d4332791fcb019d90c9b Implement GPU process shutdown. (bug 1271180 part 5, r=billm)
David Anderson <danderson@mozilla.com>
parents: 301788
diff changeset
   641
  DestroyProcess();
314601
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   642
578765
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   643
  if (mUnstableProcessAttempts >
480648
2d7b154165c0d4513a979cca61e55f115a361b1f Bug 1561825 - Make layers.* static prefs follow the naming convention. r=KrisWright
Nicholas Nethercote <nnethercote@mozilla.com>
parents: 480308
diff changeset
   644
      uint32_t(StaticPrefs::layers_gpu_process_max_restarts())) {
322428
c619e05b026ac56a056a89199319d11cb24eb518 Bug 1316988: Change the wording of the error message. r=rhunt
Milan Sreckovic <milan@mozilla.com>
parents: 322104
diff changeset
   645
    char disableMessage[64];
c619e05b026ac56a056a89199319d11cb24eb518 Bug 1316988: Change the wording of the error message. r=rhunt
Milan Sreckovic <milan@mozilla.com>
parents: 322104
diff changeset
   646
    SprintfLiteral(disableMessage, "GPU process disabled after %d attempts",
578765
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   647
                   mTotalProcessAttempts);
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   648
    if (!MaybeDisableGPUProcess(disableMessage, /* aAllowRestart */ true)) {
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   649
      // Fallback wants the GPU process. Reset our counter.
578765
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   650
      mUnstableProcessAttempts = 0;
565528
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   651
      HandleProcessLost();
8522d4a89bbd9e8bab2374efa5ceeff4a7900c0c Bug 1689203 - Allow fallback from WebRender to Software WebRender. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 565515
diff changeset
   652
    }
578765
336664d0f101004ac9b82f8adc1e8a6391639c09 Bug 1707610 - Make GPU process restart criteria depend on rendering frames and uptime. r=jrmuizel
Andrew Osmond <aosmond@mozilla.com>
parents: 578585
diff changeset
   653
  } else if (mUnstableProcessAttempts >
480648
2d7b154165c0d4513a979cca61e55f115a361b1f Bug 1561825 - Make layers.* static prefs follow the naming convention. r=KrisWright
Nicholas Nethercote <nnethercote@mozilla.com>
parents: 480308
diff changeset
   654
                 uint32_t(StaticPrefs::
2d7b154165c0d4513a979cca61e55f115a361b1f Bug 1561825 - Make layers.* static prefs follow the naming convention. r=KrisWright
Nicholas Nethercote <nnethercote@mozilla.com>
parents: 480308
diff changeset
   655
                              layers_gpu_process_max_restarts_with_decoder()) &&
353245
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
   656
             mDecodeVideoOnGpuProcess) {
353244
a373d6ae67f5bb54e905a2be8d7c2e4e2c33861c Bug 1338011 - Adds an intermediate fallback when the GPU process crashes - r=gerald
Jay Harris <jharris@mozilla.com>
parents: 352068
diff changeset
   657
    mDecodeVideoOnGpuProcess = false;
353245
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
   658
    Telemetry::Accumulate(Telemetry::GPU_PROCESS_CRASH_FALLBACKS,
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   659
                          uint32_t(FallbackType::DECODINGDISABLED));
369982
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   660
    HandleProcessLost();
353245
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
   661
  } else {
1b87f77672fda3d0d389abe6f1da470438accf97 Bug 1338011 - Adds some telemetry probes - f=bsmedberg r=gerald
Jay Harris <jharris@mozilla.com>
parents: 353244
diff changeset
   662
    Telemetry::Accumulate(Telemetry::GPU_PROCESS_CRASH_FALLBACKS,
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   663
                          uint32_t(FallbackType::NONE));
369982
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   664
    HandleProcessLost();
316040
0d3ad9d3943ab9360eb4df8f0615a34e7e32ae76 Add a testing pref to let the GPU process restart multiple times. (bug 1305941, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 315663
diff changeset
   665
  }
322104
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   666
}
473160a4dbaf251b37d2a02c9aa9b0bae5c0e2b2 Bug 1316476 - Limit the amount of device resets we allow with the gpu process. r=dvander
Ryan Hunt <rhunt@eqrion.net>
parents: 321813
diff changeset
   667
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   668
void GPUProcessManager::HandleProcessLost() {
316040
0d3ad9d3943ab9360eb4df8f0615a34e7e32ae76 Add a testing pref to let the GPU process restart multiple times. (bug 1305941, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 315663
diff changeset
   669
  if (gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
0d3ad9d3943ab9360eb4df8f0615a34e7e32ae76 Add a testing pref to let the GPU process restart multiple times. (bug 1305941, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 315663
diff changeset
   670
    LaunchGPUProcess();
0d3ad9d3943ab9360eb4df8f0615a34e7e32ae76 Add a testing pref to let the GPU process restart multiple times. (bug 1305941, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 315663
diff changeset
   671
  }
0d3ad9d3943ab9360eb4df8f0615a34e7e32ae76 Add a testing pref to let the GPU process restart multiple times. (bug 1305941, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 315663
diff changeset
   672
314602
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   673
  // The shutdown and restart sequence for the GPU process is as follows:
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   674
  //
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   675
  //  (1) The GPU process dies. IPDL will enqueue an ActorDestroy message on
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   676
  //      each channel owning a bridge to the GPU process, on the thread
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   677
  //      owning that channel.
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   678
  //
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   679
  //  (2) The first channel to process its ActorDestroy message will post a
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   680
  //      message to the main thread to call NotifyRemoteActorDestroyed on
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   681
  //      the GPUProcessManager, which calls OnProcessUnexpectedShutdown if
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   682
  //      it has not handled shutdown for this process yet.
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   683
  //
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   684
  //  (3) We then notify each widget that its session with the compositor is
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   685
  //      now invalid. The widget is responsible for destroying its layer
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   686
  //      manager and CompositorBridgeChild. Note that at this stage, not
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   687
  //      all actors may have received ActorDestroy yet. CompositorBridgeChild
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   688
  //      may attempt to send messages, and if this happens, it will probably
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   689
  //      report a MsgDropped error. This is okay.
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   690
  //
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   691
  //  (4) At this point, the UI process has a clean slate: no layers should
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   692
  //      exist for the old compositor. We may make a decision on whether or
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   693
  //      not to re-launch the GPU process. Currently, we do not relaunch it,
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   694
  //      and any new compositors will be created in-process and will default
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   695
  //      to software.
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   696
  //
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   697
  //  (5) Next we notify each ContentParent of the lost connection. It will
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   698
  //      request new endpoints from the GPUProcessManager and forward them
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   699
  //      to its ContentChild. The parent-side of these endpoints may come
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   700
  //      from the compositor thread of the UI process, or the compositor
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   701
  //      thread of the GPU process. However, no actual compositors should
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   702
  //      exist yet.
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   703
  //
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   704
  //  (6) Each ContentChild will receive new endpoints. It will destroy its
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   705
  //      Compositor/ImageBridgeChild singletons and recreate them, as well
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   706
  //      as invalidate all retained layers.
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   707
  //
470938
9813ce146bc725dd83e8ff6f41bfc36dd17d935b Bug 1534395 - Rename TabChild to BrowserChild. r=nika
Ryan Hunt <rhunt@eqrion.net>
parents: 470936
diff changeset
   708
  //  (7) In addition, each ContentChild will ask each of its BrowserChildren
314602
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   709
  //      to re-request association with the compositor for the window
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   710
  //      owning the tab. The sequence of calls looks like:
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   711
  //        (a) [CONTENT] ContentChild::RecvReinitRendering
470938
9813ce146bc725dd83e8ff6f41bfc36dd17d935b Bug 1534395 - Rename TabChild to BrowserChild. r=nika
Ryan Hunt <rhunt@eqrion.net>
parents: 470936
diff changeset
   712
  //        (b) [CONTENT] BrowserChild::ReinitRendering
9813ce146bc725dd83e8ff6f41bfc36dd17d935b Bug 1534395 - Rename TabChild to BrowserChild. r=nika
Ryan Hunt <rhunt@eqrion.net>
parents: 470936
diff changeset
   713
  //        (c) [CONTENT] BrowserChild::SendEnsureLayersConnected
470936
47813ecb1f4e0244ded2f7b938430bf52c927751 Bug 1534395 - Rename TabParent to BrowserParent. r=nika
Ryan Hunt <rhunt@eqrion.net>
parents: 470479
diff changeset
   714
  //        (d)      [UI] BrowserParent::RecvEnsureLayersConnected
444793
7151d84d01f4727761d4c4a32e4890ef12e16e70 Bug 1503655 part 11 - Rename RenderFrameParent to RenderFrame. r=kats
Ryan Hunt <rhunt@eqrion.net>
parents: 438932
diff changeset
   715
  //        (e)      [UI] RenderFrame::EnsureLayersConnected
314602
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   716
  //        (f)      [UI] CompositorBridgeChild::SendNotifyChildRecreated
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   717
  //
444793
7151d84d01f4727761d4c4a32e4890ef12e16e70 Bug 1503655 part 11 - Rename RenderFrameParent to RenderFrame. r=kats
Ryan Hunt <rhunt@eqrion.net>
parents: 438932
diff changeset
   718
  //      Note that at step (e), RenderFrame will call GetLayerManager
314602
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   719
  //      on the nsIWidget owning the tab. This step ensures that a compositor
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   720
  //      exists for the window. If we decided to launch a new GPU Process,
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   721
  //      at this point we block until the process has launched and we're
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   722
  //      able to create a new window compositor. Otherwise, if compositing
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   723
  //      is now in-process, this will simply create a new
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   724
  //      CompositorBridgeParent in the UI process. If there are multiple tabs
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   725
  //      in the same window, additional tabs will simply return the already-
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   726
  //      established compositor.
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   727
  //
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   728
  //      Finally, this step serves one other crucial function: tabs must be
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   729
  //      associated with a window compositor or else they can't forward
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   730
  //      layer transactions. So this step both ensures that a compositor
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   731
  //      exists, and that the tab can forward layers.
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   732
  //
364295
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   733
  //  (8) Last, if the window had no remote tabs, step (7) will not have
314602
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   734
  //      applied, and the window will not have a new compositor just yet.
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   735
  //      The next refresh tick and paint will ensure that one exists, again
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   736
  //      via nsIWidget::GetLayerManager.
358036
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   737
  RebuildRemoteSessions();
314602
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   738
358036
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   739
  // Notify content. This will ensure that each content process re-establishes
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   740
  // a connection to the compositor thread (whether it's in-process or in a
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   741
  // newly launched GPU process).
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   742
  for (const auto& listener : mListeners) {
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   743
    listener->OnCompositorUnexpectedShutdown();
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   744
  }
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   745
}
063adb4deaf5efe3ef4f80635dd68e15a7a0325e Handle remote device resets by recreating the entire rendering stack. (bug 1363126 part 1, r=rhunt, ipc_r=billm)
David Anderson <dvander@alliedmods.net>
parents: 354240
diff changeset
   746
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   747
void GPUProcessManager::RebuildRemoteSessions() {
314601
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   748
  // Build a list of sessions to notify, since notification might delete
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   749
  // entries from the list.
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   750
  nsTArray<RefPtr<RemoteCompositorSession>> sessions;
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   751
  for (auto& session : mRemoteSessions) {
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   752
    sessions.AppendElement(session);
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   753
  }
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   754
314602
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   755
  // Notify each widget that we have lost the GPU process. This will ensure
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
   756
  // that each widget destroys its layer manager and CompositorBridgeChild.
314601
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   757
  for (const auto& session : sessions) {
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   758
    session->NotifySessionLost();
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   759
  }
301789
9599664f3e8bbf0d1a15d4332791fcb019d90c9b Implement GPU process shutdown. (bug 1271180 part 5, r=billm)
David Anderson <danderson@mozilla.com>
parents: 301788
diff changeset
   760
}
9599664f3e8bbf0d1a15d4332791fcb019d90c9b Implement GPU process shutdown. (bug 1271180 part 5, r=billm)
David Anderson <danderson@mozilla.com>
parents: 301788
diff changeset
   761
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   762
void GPUProcessManager::RebuildInProcessSessions() {
364295
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   763
  // Build a list of sessions to notify, since notification might delete
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   764
  // entries from the list.
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   765
  nsTArray<RefPtr<InProcessCompositorSession>> sessions;
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   766
  for (auto& session : mInProcessSessions) {
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   767
    sessions.AppendElement(session);
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   768
  }
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   769
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   770
  // Notify each widget that we have lost the GPU process. This will ensure
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   771
  // that each widget destroys its layer manager and CompositorBridgeChild.
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   772
  for (const auto& session : sessions) {
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   773
    session->NotifySessionLost();
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   774
  }
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   775
}
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
   776
479274
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   777
void GPUProcessManager::NotifyDisablingWebRender() {
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   778
#if defined(MOZ_WIDGET_ANDROID)
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   779
  for (const auto& session : mRemoteSessions) {
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   780
    session->NotifyDisablingWebRender();
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   781
  }
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   782
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   783
  for (const auto& session : mInProcessSessions) {
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   784
    session->NotifyDisablingWebRender();
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   785
  }
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   786
#endif
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   787
}
548576be041b0f8a7aaf735775137b96ba286c12 Bug 1533296 - Make WebRender error as to Fallback to Compositor rendering during disabling WebRender on android r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 478280
diff changeset
   788
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   789
void GPUProcessManager::NotifyRemoteActorDestroyed(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   790
    const uint64_t& aProcessToken) {
305336
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   791
  if (!NS_IsMainThread()) {
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   792
    RefPtr<Runnable> task = mTaskFactory.NewRunnableMethod(
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   793
        &GPUProcessManager::NotifyRemoteActorDestroyed, aProcessToken);
305336
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   794
    NS_DispatchToMainThread(task.forget());
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   795
    return;
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   796
  }
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   797
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   798
  if (mProcessToken != aProcessToken) {
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   799
    // This token is for an older process; we can safely ignore it.
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   800
    return;
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   801
  }
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   802
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   803
  // One of the bridged top-level actors for the GPU process has been
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   804
  // prematurely terminated, and we're receiving a notification. This
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   805
  // can happen if the ActorDestroy for a bridged protocol fires
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   806
  // before the ActorDestroy for PGPUChild.
314601
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
   807
  OnProcessUnexpectedShutdown(mProcess);
305336
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   808
}
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   809
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   810
void GPUProcessManager::CleanShutdown() {
305740
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   811
  DestroyProcess();
316924
01fd505d5cc2621881fa344d977b5054ad055f3b Fix parent process leaks when using the GPU process. (bug 1307972, r=billm)
David Anderson <danderson@mozilla.com>
parents: 316040
diff changeset
   812
  mVsyncIOThread = nullptr;
305740
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   813
}
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
   814
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   815
void GPUProcessManager::KillProcess() {
321449
131019a5ba42fa6a492e44a20f90c37dd8e5427b Bug 1314426 - Add a method to nsIDOMWindowUtils to terminate the GPU process and get the GPU process pid r=smaug,dvander
George Wright <george@mozilla.com>
parents: 320812
diff changeset
   816
  if (!mProcess) {
131019a5ba42fa6a492e44a20f90c37dd8e5427b Bug 1314426 - Add a method to nsIDOMWindowUtils to terminate the GPU process and get the GPU process pid r=smaug,dvander
George Wright <george@mozilla.com>
parents: 320812
diff changeset
   817
    return;
131019a5ba42fa6a492e44a20f90c37dd8e5427b Bug 1314426 - Add a method to nsIDOMWindowUtils to terminate the GPU process and get the GPU process pid r=smaug,dvander
George Wright <george@mozilla.com>
parents: 320812
diff changeset
   818
  }
131019a5ba42fa6a492e44a20f90c37dd8e5427b Bug 1314426 - Add a method to nsIDOMWindowUtils to terminate the GPU process and get the GPU process pid r=smaug,dvander
George Wright <george@mozilla.com>
parents: 320812
diff changeset
   819
131019a5ba42fa6a492e44a20f90c37dd8e5427b Bug 1314426 - Add a method to nsIDOMWindowUtils to terminate the GPU process and get the GPU process pid r=smaug,dvander
George Wright <george@mozilla.com>
parents: 320812
diff changeset
   820
  mProcess->KillProcess();
131019a5ba42fa6a492e44a20f90c37dd8e5427b Bug 1314426 - Add a method to nsIDOMWindowUtils to terminate the GPU process and get the GPU process pid r=smaug,dvander
George Wright <george@mozilla.com>
parents: 320812
diff changeset
   821
}
131019a5ba42fa6a492e44a20f90c37dd8e5427b Bug 1314426 - Add a method to nsIDOMWindowUtils to terminate the GPU process and get the GPU process pid r=smaug,dvander
George Wright <george@mozilla.com>
parents: 320812
diff changeset
   822
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   823
void GPUProcessManager::DestroyProcess() {
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   824
  if (!mProcess) {
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   825
    return;
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   826
  }
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   827
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   828
  mProcess->Shutdown();
305336
1276872114941b9cb7ab00bca24bd9c322191748 Allow top-level protocols the ability to notify GPUProcessManager when their actors are unexpectedly destroyed. (bug 1282348 part 4, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305335
diff changeset
   829
  mProcessToken = 0;
301788
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   830
  mProcess = nullptr;
13f8e929e05e95d2fd76dedc146758c4d2f35461 Add skeletal code for launching a GPU process. (bug 1271180 part 4, r=billm,jrmuizel)
David Anderson <danderson@mozilla.com>
parents: 301611
diff changeset
   831
  mGPUChild = nullptr;
514406
e84157c7ee828bbca6c62ad836aaca28161dab95 Bug 1595420 - OOM in GPUProcessManager::OnPreferenceChange and RDDProcessManager::OnPreferenceChange on macOS r=mjf,jya
Haik Aftandilian <haftandilian@mozilla.com>
parents: 513762
diff changeset
   832
  mQueuedPrefs.Clear();
320812
c3c0827d6c66d6cfdacaa6ae29b24f5b924ab851 Fix shutdown crash in VsyncBridgeChild when the GPU process is enabled. (bug 1314816, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 320719
diff changeset
   833
  if (mVsyncBridge) {
c3c0827d6c66d6cfdacaa6ae29b24f5b924ab851 Fix shutdown crash in VsyncBridgeChild when the GPU process is enabled. (bug 1314816, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 320719
diff changeset
   834
    mVsyncBridge->Close();
c3c0827d6c66d6cfdacaa6ae29b24f5b924ab851 Fix shutdown crash in VsyncBridgeChild when the GPU process is enabled. (bug 1314816, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 320719
diff changeset
   835
    mVsyncBridge = nullptr;
c3c0827d6c66d6cfdacaa6ae29b24f5b924ab851 Fix shutdown crash in VsyncBridgeChild when the GPU process is enabled. (bug 1314816, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 320719
diff changeset
   836
  }
351066
328c81f2402ca1e235108167a936fd5c4c2881ed Add crash reporter annotations for the GPU process status. (bug 1343650, r=billm)
David Anderson <danderson@mozilla.com>
parents: 350753
diff changeset
   837
328c81f2402ca1e235108167a936fd5c4c2881ed Add crash reporter annotations for the GPU process status. (bug 1343650, r=billm)
David Anderson <danderson@mozilla.com>
parents: 350753
diff changeset
   838
  CrashReporter::AnnotateCrashReport(
538158
3f8100fb74318f9e0b3b6351ade737994d13bcf8 Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Simon Giesecke <sgiesecke@mozilla.com>
parents: 536944
diff changeset
   839
      CrashReporter::Annotation::GPUProcessStatus, "Destroyed"_ns);
298484
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
   840
}
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
   841
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   842
already_AddRefed<CompositorSession> GPUProcessManager::CreateTopLevelCompositor(
591057
1b49e7328ae43c6565d167f4c391430575097fd3 Bug 1727682 - Make WebRenderLayerManager not inherit LayerManager. r=jrmuizel
Matt Woodrow <mwoodrow@mozilla.com>
parents: 578765
diff changeset
   843
    nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager,
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   844
    CSSToLayoutDeviceScale aScale, const CompositorOptions& aOptions,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   845
    bool aUseExternalSurfaceSize, const gfx::IntSize& aSurfaceSize,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   846
    bool* aRetryOut) {
369982
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   847
  MOZ_ASSERT(aRetryOut);
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   848
409886
5d9f32557d7740c7c30f7bc6057c4de0c294d828 Bug 1448490 - Make the layers id a struct instead of a uint64_t. r=mattwoodrow
Kartikaya Gupta <kgupta@mozilla.com>
parents: 408582
diff changeset
   849
  LayersId layerTreeId = AllocateLayerTreeId();
305335
f26200be9e80dcab281d843d4cc3ce70fe2fbc1a Move layers ID allocation to GPUProcessManager. (bug 1282348 part 3, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 305334
diff changeset
   850
366622
8df38aa687818bf3254353693d98633c58dd875f Bug 1376590 - When disabling the GPU process, ensure its dependencies are initialized for the same process. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 366036
diff changeset
   851
  EnsureProtocolsReady();
354240
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   852
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   853
  RefPtr<CompositorSession> session;
305809
56f707cd8725ee328b9e0d3dd2342a56b2bea119 Move parent-process ImageBridgeChild startup to GPUProcessManager. (bug 1287366 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 305742
diff changeset
   854
350455
50907f304e247c56192bdd4af58159b4cdab46b8 Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
vincentliu <vliu@mozilla.com>
parents: 348222
diff changeset
   855
  if (EnsureGPUReady()) {
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   856
    session =
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   857
        CreateRemoteSession(aWidget, aLayerManager, layerTreeId, aScale,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   858
                            aOptions, aUseExternalSurfaceSize, aSurfaceSize);
354240
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   859
    if (!session) {
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   860
      // We couldn't create a remote compositor, so abort the process.
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   861
      DisableGPUProcess("Failed to create remote compositor");
369982
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   862
      *aRetryOut = true;
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   863
      return nullptr;
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   864
    }
369982
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   865
  } else {
354240
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   866
    session = InProcessCompositorSession::Create(
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   867
        aWidget, aLayerManager, layerTreeId, aScale, aOptions,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   868
        aUseExternalSurfaceSize, aSurfaceSize, AllocateNamespace());
354240
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   869
  }
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   870
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   871
#if defined(MOZ_WIDGET_ANDROID)
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   872
  if (session) {
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   873
    // Nothing to do if controller gets a nullptr
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   874
    RefPtr<UiCompositorControllerChild> controller =
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   875
        CreateUiCompositorController(aWidget, session->RootLayerTreeId());
354240
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   876
    session->SetUiCompositorControllerChild(controller);
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   877
  }
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   878
#endif  // defined(MOZ_WIDGET_ANDROID)
354240
81de9d1439b0e352729142f6aa2914674073da03 Bug 1335895 - Android GeckoView Dynamic Toolbar Version 3 r=botond,dvander,jchen,kats
Randall Barker <rbarker@mozilla.com>
parents: 353424
diff changeset
   879
369982
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   880
  *aRetryOut = false;
05e705204d3bced8e56631b0ef6fe2abe65710c7 Bug 1381095 - Fallback correctly to non-WebRender if the GPU process/WebRender are disabled when creating a remote compositor session. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 369587
diff changeset
   881
  return session.forget();
298484
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
   882
}
a22a53c503a6852c1cc663f2000662b561999af2 Add GPUProcessManager to manage access to CompositorBridgeParent. (bug 1274149 part 1, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents:
diff changeset
   883
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   884
RefPtr<CompositorSession> GPUProcessManager::CreateRemoteSession(
591057
1b49e7328ae43c6565d167f4c391430575097fd3 Bug 1727682 - Make WebRenderLayerManager not inherit LayerManager. r=jrmuizel
Matt Woodrow <mwoodrow@mozilla.com>
parents: 578765
diff changeset
   885
    nsBaseWidget* aWidget, WebRenderLayerManager* aLayerManager,
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   886
    const LayersId& aRootLayerTreeId, CSSToLayoutDeviceScale aScale,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   887
    const CompositorOptions& aOptions, bool aUseExternalSurfaceSize,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   888
    const gfx::IntSize& aSurfaceSize) {
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   889
#ifdef MOZ_WIDGET_SUPPORTS_OOP_COMPOSITING
522159
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
   890
  widget::CompositorWidgetInitData initData;
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   891
  aWidget->GetCompositorWidgetInitData(&initData);
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   892
364055
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   893
  RefPtr<CompositorBridgeChild> child =
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   894
      CompositorManagerChild::CreateWidgetCompositorBridge(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   895
          mProcessToken, aLayerManager, AllocateNamespace(), aScale, aOptions,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   896
          aUseExternalSurfaceSize, aSurfaceSize);
364055
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   897
  if (!child) {
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   898
    gfxCriticalNote << "Failed to create CompositorBridgeChild";
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   899
    return nullptr;
305811
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   900
  }
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   901
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   902
  RefPtr<CompositorVsyncDispatcher> dispatcher =
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   903
      aWidget->GetCompositorVsyncDispatcher();
522159
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
   904
  RefPtr<widget::CompositorWidgetVsyncObserver> observer =
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
   905
      new widget::CompositorWidgetVsyncObserver(mVsyncBridge, aRootLayerTreeId);
305742
3fdb8ca3e6ffbd310daf342eb8febb1c17938dd0 Implement vsync notification for remote compositors. (bug 1285625 part 3, r=mchang)
David Anderson <danderson@mozilla.com>
parents: 305740
diff changeset
   906
522159
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
   907
  widget::CompositorWidgetChild* widget =
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
   908
      new widget::CompositorWidgetChild(dispatcher, observer, initData);
305811
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   909
  if (!child->SendPCompositorWidgetConstructor(widget, initData)) {
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   910
    return nullptr;
305811
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   911
  }
509764
0e1d591422956f3a8e9c372f31e3b3e413f73e65 Bug 1604412 - Give CompositorWidgetChild more window info r=sotaro
Chris Martin <cmartin@mozilla.com>
parents: 509611
diff changeset
   912
  if (!widget->Initialize()) {
0e1d591422956f3a8e9c372f31e3b3e413f73e65 Bug 1604412 - Give CompositorWidgetChild more window info r=sotaro
Chris Martin <cmartin@mozilla.com>
parents: 509611
diff changeset
   913
    return nullptr;
0e1d591422956f3a8e9c372f31e3b3e413f73e65 Bug 1604412 - Give CompositorWidgetChild more window info r=sotaro
Chris Martin <cmartin@mozilla.com>
parents: 509611
diff changeset
   914
  }
305811
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   915
  if (!child->SendInitialize(aRootLayerTreeId)) {
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   916
    return nullptr;
305811
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
   917
  }
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   918
311694
81de0e995050eb75595ba97d9ccfee2f96c9ddff Bug 1298245 - Hook up creation of OOP APZ for main process. r=dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311192
diff changeset
   919
  RefPtr<APZCTreeManagerChild> apz = nullptr;
329203
3d27c7cbcafa48642e0368319c563c4e32895242 Bug 1330037 - Introduce a CompositorOptions struct that holds options on a per-compositor basis. r=dvander
Kartikaya Gupta <kgupta@mozilla.com>
parents: 322995
diff changeset
   920
  if (aOptions.UseAPZ()) {
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   921
    PAPZCTreeManagerChild* papz =
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   922
        child->SendPAPZCTreeManagerConstructor(LayersId{0});
311694
81de0e995050eb75595ba97d9ccfee2f96c9ddff Bug 1298245 - Hook up creation of OOP APZ for main process. r=dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311192
diff changeset
   923
    if (!papz) {
81de0e995050eb75595ba97d9ccfee2f96c9ddff Bug 1298245 - Hook up creation of OOP APZ for main process. r=dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311192
diff changeset
   924
      return nullptr;
81de0e995050eb75595ba97d9ccfee2f96c9ddff Bug 1298245 - Hook up creation of OOP APZ for main process. r=dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311192
diff changeset
   925
    }
81de0e995050eb75595ba97d9ccfee2f96c9ddff Bug 1298245 - Hook up creation of OOP APZ for main process. r=dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311192
diff changeset
   926
    apz = static_cast<APZCTreeManagerChild*>(papz);
408582
91e7da46a9b1175e27bacc83acbd5621f15a7600 Bug 1441324 - Introduce an empty APZInputBridge protocol managed by PGPU. r=rhunt
Kartikaya Gupta <kgupta@mozilla.com>
parents: 406736
diff changeset
   927
487110
690edc0673c61f056f8a4106237f79b1f6a734ba Bug 1570369 - Part 2: Use IPDL refcounted for PAPZInputBridge, r=rhunt
Nika Layzell <nika@thelayzells.com>
parents: 484792
diff changeset
   928
    RefPtr<APZInputBridgeChild> pinput = new APZInputBridgeChild();
690edc0673c61f056f8a4106237f79b1f6a734ba Bug 1570369 - Part 2: Use IPDL refcounted for PAPZInputBridge, r=rhunt
Nika Layzell <nika@thelayzells.com>
parents: 484792
diff changeset
   929
    if (!mGPUChild->SendPAPZInputBridgeConstructor(pinput, aRootLayerTreeId)) {
408582
91e7da46a9b1175e27bacc83acbd5621f15a7600 Bug 1441324 - Introduce an empty APZInputBridge protocol managed by PGPU. r=rhunt
Kartikaya Gupta <kgupta@mozilla.com>
parents: 406736
diff changeset
   930
      return nullptr;
91e7da46a9b1175e27bacc83acbd5621f15a7600 Bug 1441324 - Introduce an empty APZInputBridge protocol managed by PGPU. r=rhunt
Kartikaya Gupta <kgupta@mozilla.com>
parents: 406736
diff changeset
   931
    }
487110
690edc0673c61f056f8a4106237f79b1f6a734ba Bug 1570369 - Part 2: Use IPDL refcounted for PAPZInputBridge, r=rhunt
Nika Layzell <nika@thelayzells.com>
parents: 484792
diff changeset
   932
    apz->SetInputBridge(pinput);
311694
81de0e995050eb75595ba97d9ccfee2f96c9ddff Bug 1298245 - Hook up creation of OOP APZ for main process. r=dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311192
diff changeset
   933
  }
81de0e995050eb75595ba97d9ccfee2f96c9ddff Bug 1298245 - Hook up creation of OOP APZ for main process. r=dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311192
diff changeset
   934
513762
49adcf9a70abc9df4f11a123d181aa7213a20615 Bug 1611415 - Prefer using std::move over forget. r=froydnj
Simon Giesecke <sgiesecke@mozilla.com>
parents: 513586
diff changeset
   935
  return new RemoteCompositorSession(aWidget, child, widget, apz,
49adcf9a70abc9df4f11a123d181aa7213a20615 Bug 1611415 - Prefer using std::move over forget. r=froydnj
Simon Giesecke <sgiesecke@mozilla.com>
parents: 513586
diff changeset
   936
                                     aRootLayerTreeId);
305337
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   937
#else
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   938
  gfxCriticalNote << "Platform does not support out-of-process compositing";
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   939
  return nullptr;
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   940
#endif
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   941
}
e6bd9062617fecf80cf520885e367776d02c9745 Add a remote implementation of CompositorSession. (bug 1282348 part 5, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 305336
diff changeset
   942
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   943
bool GPUProcessManager::CreateContentBridges(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   944
    base::ProcessId aOtherProcess,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   945
    ipc::Endpoint<PCompositorManagerChild>* aOutCompositor,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   946
    ipc::Endpoint<PImageBridgeChild>* aOutImageBridge,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   947
    ipc::Endpoint<PVRManagerChild>* aOutVRBridge,
478151
a1198059b0809f9c752511256aaaec26a2c56a29 Bug 1555891 - Merge PVideoDecoderManager into PRemoteDecoderManager. r=jya,jld
Matt Woodrow <mwoodrow@mozilla.com>
parents: 475617
diff changeset
   948
    ipc::Endpoint<PRemoteDecoderManagerChild>* aOutVideoManager,
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   949
    nsTArray<uint32_t>* aNamespaces) {
364055
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   950
  if (!CreateContentCompositorManager(aOtherProcess, aOutCompositor) ||
314600
320c9cc8fc52abac4589b185a1897b7270e5943e Send content compositor bridges atomically rather than individually. (bug 1300936 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 314336
diff changeset
   951
      !CreateContentImageBridge(aOtherProcess, aOutImageBridge) ||
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   952
      !CreateContentVRManager(aOtherProcess, aOutVRBridge)) {
314600
320c9cc8fc52abac4589b185a1897b7270e5943e Send content compositor bridges atomically rather than individually. (bug 1300936 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 314336
diff changeset
   953
    return false;
320c9cc8fc52abac4589b185a1897b7270e5943e Send content compositor bridges atomically rather than individually. (bug 1300936 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 314336
diff changeset
   954
  }
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   955
  // VideoDeocderManager is only supported in the GPU process, so we allow this
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   956
  // to be fallible.
478151
a1198059b0809f9c752511256aaaec26a2c56a29 Bug 1555891 - Merge PVideoDecoderManager into PRemoteDecoderManager. r=jya,jld
Matt Woodrow <mwoodrow@mozilla.com>
parents: 475617
diff changeset
   957
  CreateContentRemoteDecoderManager(aOtherProcess, aOutVideoManager);
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   958
  // Allocates 3 namespaces(for CompositorManagerChild, CompositorBridgeChild
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   959
  // and ImageBridgeChild)
364055
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   960
  aNamespaces->AppendElement(AllocateNamespace());
353420
de44ef87432b3ca50dff0fc3c4a76b2d539d1ac8 Bug 1356190 - Fix GetNextExternalImageId() r=jrmuizel
sotaro <sotaro.ikeda.g@gmail.com>
parents: 352068
diff changeset
   961
  aNamespaces->AppendElement(AllocateNamespace());
de44ef87432b3ca50dff0fc3c4a76b2d539d1ac8 Bug 1356190 - Fix GetNextExternalImageId() r=jrmuizel
sotaro <sotaro.ikeda.g@gmail.com>
parents: 352068
diff changeset
   962
  aNamespaces->AppendElement(AllocateNamespace());
314600
320c9cc8fc52abac4589b185a1897b7270e5943e Send content compositor bridges atomically rather than individually. (bug 1300936 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 314336
diff changeset
   963
  return true;
320c9cc8fc52abac4589b185a1897b7270e5943e Send content compositor bridges atomically rather than individually. (bug 1300936 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 314336
diff changeset
   964
}
320c9cc8fc52abac4589b185a1897b7270e5943e Send content compositor bridges atomically rather than individually. (bug 1300936 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 314336
diff changeset
   965
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   966
bool GPUProcessManager::CreateContentCompositorManager(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   967
    base::ProcessId aOtherProcess,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   968
    ipc::Endpoint<PCompositorManagerChild>* aOutEndpoint) {
364055
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   969
  ipc::Endpoint<PCompositorManagerParent> parentPipe;
ee612156fa6fda194395393006314d2209ff6038 Bug 1365927 - Part 4. Replace PCompositorBridge integration hooks with PCompositorManager. r=dvander
Andrew Osmond <aosmond@mozilla.com>
parents: 363766
diff changeset
   970
  ipc::Endpoint<PCompositorManagerChild> childPipe;
305339
39636df7a0fe56efe6e0480df7cbb707d18c70b3 Send content compositor bridges using endpoints rather than Opens. (bug 1282348 part 7, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305337
diff changeset
   971
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   972
  base::ProcessId parentPid =
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   973
      EnsureGPUReady() ? mGPUChild->OtherPid() : base::GetCurrentProcId();
305340
b09494ecac5f068861315f9a160fb70e7544e1f6 Support compositor bridges from the content process to the GPU process. (bug 1282348 part 8, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305339
diff changeset
   974
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   975
  nsresult rv = PCompositorManager::CreateEndpoints(parentPid, aOtherProcess,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   976
                                                    &parentPipe, &childPipe);
305339
39636df7a0fe56efe6e0480df7cbb707d18c70b3 Send content compositor bridges using endpoints rather than Opens. (bug 1282348 part 7, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305337
diff changeset
   977
  if (NS_FAILED(rv)) {
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   978
    gfxCriticalNote << "Could not create content compositor manager: "
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   979
                    << hexa(int(rv));
305339
39636df7a0fe56efe6e0480df7cbb707d18c70b3 Send content compositor bridges using endpoints rather than Opens. (bug 1282348 part 7, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305337
diff changeset
   980
    return false;
39636df7a0fe56efe6e0480df7cbb707d18c70b3 Send content compositor bridges using endpoints rather than Opens. (bug 1282348 part 7, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305337
diff changeset
   981
  }
39636df7a0fe56efe6e0480df7cbb707d18c70b3 Send content compositor bridges using endpoints rather than Opens. (bug 1282348 part 7, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305337
diff changeset
   982
366860
a45473c94b8d07e95ad176d092fdd5361bf9a378 Fix race where in-process GPU endpoints could have the wrong PID. (bug 1374258, r=rhunt)
David Anderson <danderson@mozilla.com>
parents: 366622
diff changeset
   983
  if (mGPUChild) {
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
   984
    mGPUChild->SendNewContentCompositorManager(std::move(parentPipe));
470479
faab5ee080b68acb0eff49bf0a9f3db10ad44a8d Bug 1546298 - Set CompositorManagerParent::sInstance in GPU process r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 466261
diff changeset
   985
  } else if (!CompositorManagerParent::Create(std::move(parentPipe),
faab5ee080b68acb0eff49bf0a9f3db10ad44a8d Bug 1546298 - Set CompositorManagerParent::sInstance in GPU process r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 466261
diff changeset
   986
                                              /* aIsRoot */ false)) {
466261
37b25f761caeacbbc9ad79343631acc9c43855c5 Bug 1534749 - Handle shutdown races between the compositor thread and IPDL object setup. r=rhunt
Andrew Osmond <aosmond@mozilla.com>
parents: 461818
diff changeset
   987
    return false;
305340
b09494ecac5f068861315f9a160fb70e7544e1f6 Support compositor bridges from the content process to the GPU process. (bug 1282348 part 8, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305339
diff changeset
   988
  }
305339
39636df7a0fe56efe6e0480df7cbb707d18c70b3 Send content compositor bridges using endpoints rather than Opens. (bug 1282348 part 7, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305337
diff changeset
   989
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
   990
  *aOutEndpoint = std::move(childPipe);
305339
39636df7a0fe56efe6e0480df7cbb707d18c70b3 Send content compositor bridges using endpoints rather than Opens. (bug 1282348 part 7, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305337
diff changeset
   991
  return true;
298488
1117598ac87588b13931fcee5a519f70eedd0a59 Remove ContentParent use of CompositorBridgeParent. (bug 1274149 part 5, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 298487
diff changeset
   992
}
1117598ac87588b13931fcee5a519f70eedd0a59 Remove ContentParent use of CompositorBridgeParent. (bug 1274149 part 5, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 298487
diff changeset
   993
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   994
bool GPUProcessManager::CreateContentImageBridge(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   995
    base::ProcessId aOtherProcess,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   996
    ipc::Endpoint<PImageBridgeChild>* aOutEndpoint) {
305810
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
   997
  EnsureImageBridgeChild();
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
   998
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
   999
  base::ProcessId parentPid =
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1000
      EnsureGPUReady() ? mGPUChild->OtherPid() : base::GetCurrentProcId();
305810
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
  1001
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
  1002
  ipc::Endpoint<PImageBridgeParent> parentPipe;
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
  1003
  ipc::Endpoint<PImageBridgeChild> childPipe;
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1004
  nsresult rv = PImageBridge::CreateEndpoints(parentPid, aOtherProcess,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1005
                                              &parentPipe, &childPipe);
305810
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
  1006
  if (NS_FAILED(rv)) {
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1007
    gfxCriticalNote << "Could not create content compositor bridge: "
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1008
                    << hexa(int(rv));
305810
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
  1009
    return false;
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
  1010
  }
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
  1011
366860
a45473c94b8d07e95ad176d092fdd5361bf9a378 Fix race where in-process GPU endpoints could have the wrong PID. (bug 1374258, r=rhunt)
David Anderson <danderson@mozilla.com>
parents: 366622
diff changeset
  1012
  if (mGPUChild) {
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
  1013
    mGPUChild->SendNewContentImageBridge(std::move(parentPipe));
305811
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
  1014
  } else {
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
  1015
    if (!ImageBridgeParent::CreateForContent(std::move(parentPipe))) {
305811
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
  1016
      return false;
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
  1017
    }
a0f0837ba27de9a5d109c74ae860229ae425abfa Implement ImageBridge support for the GPU process. (bug 1287366 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 305810
diff changeset
  1018
  }
305810
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
  1019
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
  1020
  *aOutEndpoint = std::move(childPipe);
305810
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
  1021
  return true;
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
  1022
}
f4a1a01e9eda05d889457a25e315b43ad7fc0e66 Use Endpoints for content-process ImageBridges. (bug 1287366 part 2, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305809
diff changeset
  1023
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1024
base::ProcessId GPUProcessManager::GPUProcessPid() {
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1025
  base::ProcessId gpuPid = mGPUChild ? mGPUChild->OtherPid() : -1;
321449
131019a5ba42fa6a492e44a20f90c37dd8e5427b Bug 1314426 - Add a method to nsIDOMWindowUtils to terminate the GPU process and get the GPU process pid r=smaug,dvander
George Wright <george@mozilla.com>
parents: 320812
diff changeset
  1026
  return gpuPid;
131019a5ba42fa6a492e44a20f90c37dd8e5427b Bug 1314426 - Add a method to nsIDOMWindowUtils to terminate the GPU process and get the GPU process pid r=smaug,dvander
George Wright <george@mozilla.com>
parents: 320812
diff changeset
  1027
}
131019a5ba42fa6a492e44a20f90c37dd8e5427b Bug 1314426 - Add a method to nsIDOMWindowUtils to terminate the GPU process and get the GPU process pid r=smaug,dvander
George Wright <george@mozilla.com>
parents: 320812
diff changeset
  1028
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1029
bool GPUProcessManager::CreateContentVRManager(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1030
    base::ProcessId aOtherProcess,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1031
    ipc::Endpoint<PVRManagerChild>* aOutEndpoint) {
306036
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
  1032
  EnsureVRManager();
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
  1033
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1034
  base::ProcessId parentPid =
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1035
      EnsureGPUReady() ? mGPUChild->OtherPid() : base::GetCurrentProcId();
306034
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1036
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1037
  ipc::Endpoint<PVRManagerParent> parentPipe;
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1038
  ipc::Endpoint<PVRManagerChild> childPipe;
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1039
  nsresult rv = PVRManager::CreateEndpoints(parentPid, aOtherProcess,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1040
                                            &parentPipe, &childPipe);
306034
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1041
  if (NS_FAILED(rv)) {
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1042
    gfxCriticalNote << "Could not create content compositor bridge: "
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1043
                    << hexa(int(rv));
306034
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1044
    return false;
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1045
  }
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1046
366860
a45473c94b8d07e95ad176d092fdd5361bf9a378 Fix race where in-process GPU endpoints could have the wrong PID. (bug 1374258, r=rhunt)
David Anderson <danderson@mozilla.com>
parents: 366622
diff changeset
  1047
  if (mGPUChild) {
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
  1048
    mGPUChild->SendNewContentVRManager(std::move(parentPipe));
306036
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
  1049
  } else {
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
  1050
    if (!VRManagerParent::CreateForContent(std::move(parentPipe))) {
306036
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
  1051
      return false;
04cf459f7fc6e0315fe8c0978b83f5ac8e0ec37d Add VRManager support to the GPU process. (bug 1287597 part 3, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306035
diff changeset
  1052
    }
306034
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1053
  }
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1054
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
  1055
  *aOutEndpoint = std::move(childPipe);
306034
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1056
  return true;
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1057
}
6f859f324dce2551bd30d42a0bce38f2134e35a9 Open content VRManagers using endpoints. (bug 1287597 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 306008
diff changeset
  1058
478151
a1198059b0809f9c752511256aaaec26a2c56a29 Bug 1555891 - Merge PVideoDecoderManager into PRemoteDecoderManager. r=jya,jld
Matt Woodrow <mwoodrow@mozilla.com>
parents: 475617
diff changeset
  1059
void GPUProcessManager::CreateContentRemoteDecoderManager(
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1060
    base::ProcessId aOtherProcess,
478151
a1198059b0809f9c752511256aaaec26a2c56a29 Bug 1555891 - Merge PVideoDecoderManager into PRemoteDecoderManager. r=jya,jld
Matt Woodrow <mwoodrow@mozilla.com>
parents: 475617
diff changeset
  1061
    ipc::Endpoint<PRemoteDecoderManagerChild>* aOutEndpoint) {
480744
3780202d7104307ec4c5f4a1dde788e5123c47ac Bug 1562331 - Make media.* static prefs follow the naming convention. r=KrisWright
Nicholas Nethercote <nnethercote@mozilla.com>
parents: 480648
diff changeset
  1062
  if (!EnsureGPUReady() || !StaticPrefs::media_gpu_process_decoder() ||
353244
a373d6ae67f5bb54e905a2be8d7c2e4e2c33861c Bug 1338011 - Adds an intermediate fallback when the GPU process crashes - r=gerald
Jay Harris <jharris@mozilla.com>
parents: 352068
diff changeset
  1063
      !mDecodeVideoOnGpuProcess) {
321799
95ab9f05b980662a420d6d664c1996c0dfb8e4c8 Bug 1315510 - Automatically recreate VideoDecoderManager if the GPU process crashes. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 321756
diff changeset
  1064
    return;
314817
77f9319fb6f63f31621c56920fe19fca6863f868 Bug 1288618 - Part 13: Add VideoDecoderManager protocol. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 314699
diff changeset
  1065
  }
77f9319fb6f63f31621c56920fe19fca6863f868 Bug 1288618 - Part 13: Add VideoDecoderManager protocol. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 314699
diff changeset
  1066
478151
a1198059b0809f9c752511256aaaec26a2c56a29 Bug 1555891 - Merge PVideoDecoderManager into PRemoteDecoderManager. r=jya,jld
Matt Woodrow <mwoodrow@mozilla.com>
parents: 475617
diff changeset
  1067
  ipc::Endpoint<PRemoteDecoderManagerParent> parentPipe;
a1198059b0809f9c752511256aaaec26a2c56a29 Bug 1555891 - Merge PVideoDecoderManager into PRemoteDecoderManager. r=jya,jld
Matt Woodrow <mwoodrow@mozilla.com>
parents: 475617
diff changeset
  1068
  ipc::Endpoint<PRemoteDecoderManagerChild> childPipe;
314817
77f9319fb6f63f31621c56920fe19fca6863f868 Bug 1288618 - Part 13: Add VideoDecoderManager protocol. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 314699
diff changeset
  1069
478151
a1198059b0809f9c752511256aaaec26a2c56a29 Bug 1555891 - Merge PVideoDecoderManager into PRemoteDecoderManager. r=jya,jld
Matt Woodrow <mwoodrow@mozilla.com>
parents: 475617
diff changeset
  1070
  nsresult rv = PRemoteDecoderManager::CreateEndpoints(
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1071
      mGPUChild->OtherPid(), aOtherProcess, &parentPipe, &childPipe);
314817
77f9319fb6f63f31621c56920fe19fca6863f868 Bug 1288618 - Part 13: Add VideoDecoderManager protocol. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 314699
diff changeset
  1072
  if (NS_FAILED(rv)) {
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1073
    gfxCriticalNote << "Could not create content video decoder: "
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1074
                    << hexa(int(rv));
321799
95ab9f05b980662a420d6d664c1996c0dfb8e4c8 Bug 1315510 - Automatically recreate VideoDecoderManager if the GPU process crashes. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 321756
diff changeset
  1075
    return;
314817
77f9319fb6f63f31621c56920fe19fca6863f868 Bug 1288618 - Part 13: Add VideoDecoderManager protocol. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 314699
diff changeset
  1076
  }
77f9319fb6f63f31621c56920fe19fca6863f868 Bug 1288618 - Part 13: Add VideoDecoderManager protocol. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 314699
diff changeset
  1077
478151
a1198059b0809f9c752511256aaaec26a2c56a29 Bug 1555891 - Merge PVideoDecoderManager into PRemoteDecoderManager. r=jya,jld
Matt Woodrow <mwoodrow@mozilla.com>
parents: 475617
diff changeset
  1078
  mGPUChild->SendNewContentRemoteDecoderManager(std::move(parentPipe));
314817
77f9319fb6f63f31621c56920fe19fca6863f868 Bug 1288618 - Part 13: Add VideoDecoderManager protocol. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 314699
diff changeset
  1079
420862
b54db66223586b4e04f5cb926fccdacf8a176b91 Bug 1465585: Switch from mozilla::Move to std::move. r=froydnj
Emilio Cobos Álvarez <emilio@crisal.io>
parents: 417365
diff changeset
  1080
  *aOutEndpoint = std::move(childPipe);
314817
77f9319fb6f63f31621c56920fe19fca6863f868 Bug 1288618 - Part 13: Add VideoDecoderManager protocol. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 314699
diff changeset
  1081
}
77f9319fb6f63f31621c56920fe19fca6863f868 Bug 1288618 - Part 13: Add VideoDecoderManager protocol. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 314699
diff changeset
  1082
503843
8e9c25f6c1ec1ecbae8eb0506696cc9214be9096 Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
Sylvestre Ledru <sledru@mozilla.com>
parents: 500315
diff changeset
  1083
void GPUProcessManager::InitVideoBridge(
8e9c25f6c1ec1ecbae8eb0506696cc9214be9096 Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan
Sylvestre Ledru <sledru@mozilla.com>
parents: 500315
diff changeset
  1084
    ipc::Endpoint<PVideoBridgeParent>&& aVideoBridge) {
500315
e4d3547739db667cecbcb571c5f9a0cbb6a484a8 Bug 1561179 - P4: Create PVideoBridge between RDDProcess and GPUProcess. r=mattwoodrow
Dan Glastonbury <dan.glastonbury@gmail.com>
parents: 499913
diff changeset
  1085
  if (EnsureGPUReady()) {
e4d3547739db667cecbcb571c5f9a0cbb6a484a8 Bug 1561179 - P4: Create PVideoBridge between RDDProcess and GPUProcess. r=mattwoodrow
Dan Glastonbury <dan.glastonbury@gmail.com>
parents: 499913
diff changeset
  1086
    mGPUChild->SendInitVideoBridge(std::move(aVideoBridge));
e4d3547739db667cecbcb571c5f9a0cbb6a484a8 Bug 1561179 - P4: Create PVideoBridge between RDDProcess and GPUProcess. r=mattwoodrow
Dan Glastonbury <dan.glastonbury@gmail.com>
parents: 499913
diff changeset
  1087
  }
e4d3547739db667cecbcb571c5f9a0cbb6a484a8 Bug 1561179 - P4: Create PVideoBridge between RDDProcess and GPUProcess. r=mattwoodrow
Dan Glastonbury <dan.glastonbury@gmail.com>
parents: 499913
diff changeset
  1088
}
e4d3547739db667cecbcb571c5f9a0cbb6a484a8 Bug 1561179 - P4: Create PVideoBridge between RDDProcess and GPUProcess. r=mattwoodrow
Dan Glastonbury <dan.glastonbury@gmail.com>
parents: 499913
diff changeset
  1089
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1090
void GPUProcessManager::MapLayerTreeId(LayersId aLayersId,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1091
                                       base::ProcessId aOwningId) {
311190
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
  1092
  LayerTreeOwnerTracker::Get()->Map(aLayersId, aOwningId);
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
  1093
350455
50907f304e247c56192bdd4af58159b4cdab46b8 Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
vincentliu <vliu@mozilla.com>
parents: 348222
diff changeset
  1094
  if (EnsureGPUReady()) {
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1095
    mGPUChild->SendAddLayerTreeIdMapping(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1096
        LayerTreeIdMapping(aLayersId, aOwningId));
311190
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
  1097
  }
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
  1098
}
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
  1099
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1100
void GPUProcessManager::UnmapLayerTreeId(LayersId aLayersId,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1101
                                         base::ProcessId aOwningId) {
320719
d02c16e38045c171dc288bcb60546747ab439f34 Bug 1314186 - Resync LayerTreeId mappings to the GPU process if it restarts. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 320537
diff changeset
  1102
  LayerTreeOwnerTracker::Get()->Unmap(aLayersId, aOwningId);
d02c16e38045c171dc288bcb60546747ab439f34 Bug 1314186 - Resync LayerTreeId mappings to the GPU process if it restarts. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 320537
diff changeset
  1103
350455
50907f304e247c56192bdd4af58159b4cdab46b8 Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
vincentliu <vliu@mozilla.com>
parents: 348222
diff changeset
  1104
  if (EnsureGPUReady()) {
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1105
    mGPUChild->SendRemoveLayerTreeIdMapping(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1106
        LayerTreeIdMapping(aLayersId, aOwningId));
320719
d02c16e38045c171dc288bcb60546747ab439f34 Bug 1314186 - Resync LayerTreeId mappings to the GPU process if it restarts. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 320537
diff changeset
  1107
    return;
d02c16e38045c171dc288bcb60546747ab439f34 Bug 1314186 - Resync LayerTreeId mappings to the GPU process if it restarts. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 320537
diff changeset
  1108
  }
d02c16e38045c171dc288bcb60546747ab439f34 Bug 1314186 - Resync LayerTreeId mappings to the GPU process if it restarts. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 320537
diff changeset
  1109
  CompositorBridgeParent::DeallocateLayerTreeId(aLayersId);
d02c16e38045c171dc288bcb60546747ab439f34 Bug 1314186 - Resync LayerTreeId mappings to the GPU process if it restarts. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 320537
diff changeset
  1110
}
d02c16e38045c171dc288bcb60546747ab439f34 Bug 1314186 - Resync LayerTreeId mappings to the GPU process if it restarts. r=dvander
Matt Woodrow <mwoodrow@mozilla.com>
parents: 320537
diff changeset
  1111
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1112
bool GPUProcessManager::IsLayerTreeIdMapped(LayersId aLayersId,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1113
                                            base::ProcessId aRequestingId) {
311190
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
  1114
  return LayerTreeOwnerTracker::Get()->IsMapped(aLayersId, aRequestingId);
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
  1115
}
5a883a5ff328b2de99c7cab5f1bcc04534dcda6f Bug 1289650 - Check the owning PID when creating PAPZCTreeManager, PLayerTransaction. r=kats,dvander
Ryan Hunt <rhunt@mozilla.com>
parents: 311045
diff changeset
  1116
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1117
LayersId GPUProcessManager::AllocateLayerTreeId() {
361247
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1118
  // Allocate tree id by using id namespace.
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1119
  // By it, tree id does not conflict with external image id and
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1120
  // async image pipeline id.
305335
f26200be9e80dcab281d843d4cc3ce70fe2fbc1a Move layers ID allocation to GPUProcessManager. (bug 1282348 part 3, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 305334
diff changeset
  1121
  MOZ_ASSERT(NS_IsMainThread());
361247
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1122
  ++mResourceId;
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1123
  if (mResourceId == UINT32_MAX) {
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1124
    // Move to next id namespace.
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1125
    mIdNamespace = AllocateNamespace();
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1126
    mResourceId = 1;
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1127
  }
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1128
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1129
  uint64_t layerTreeId = mIdNamespace;
392436e4adff730e3d8da332bcde199bd1151a7b Bug 1366915 part 2 - Make CompositorBridgeChild allocate pipeline id for async image pipeline r=nical
sotaro <sotaro.ikeda.g@gmail.com>
parents: 358038
diff changeset
  1130
  layerTreeId = (layerTreeId << 32) | mResourceId;
409886
5d9f32557d7740c7c30f7bc6057c4de0c294d828 Bug 1448490 - Make the layers id a struct instead of a uint64_t. r=mattwoodrow
Kartikaya Gupta <kgupta@mozilla.com>
parents: 408582
diff changeset
  1131
  return LayersId{layerTreeId};
298486
057223823e5d0a75b1925121274dcfee18c70a43 Move Alloc/DeallocLayerTreeId calls to GPUProcessManager. (bug 1274149 part 3, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 298485
diff changeset
  1132
}
057223823e5d0a75b1925121274dcfee18c70a43 Move Alloc/DeallocLayerTreeId calls to GPUProcessManager. (bug 1274149 part 3, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 298485
diff changeset
  1133
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1134
uint32_t GPUProcessManager::AllocateNamespace() {
353420
de44ef87432b3ca50dff0fc3c4a76b2d539d1ac8 Bug 1356190 - Fix GetNextExternalImageId() r=jrmuizel
sotaro <sotaro.ikeda.g@gmail.com>
parents: 352068
diff changeset
  1135
  MOZ_ASSERT(NS_IsMainThread());
de44ef87432b3ca50dff0fc3c4a76b2d539d1ac8 Bug 1356190 - Fix GetNextExternalImageId() r=jrmuizel
sotaro <sotaro.ikeda.g@gmail.com>
parents: 352068
diff changeset
  1136
  return ++mNextNamespace;
de44ef87432b3ca50dff0fc3c4a76b2d539d1ac8 Bug 1356190 - Fix GetNextExternalImageId() r=jrmuizel
sotaro <sotaro.ikeda.g@gmail.com>
parents: 352068
diff changeset
  1137
}
de44ef87432b3ca50dff0fc3c4a76b2d539d1ac8 Bug 1356190 - Fix GetNextExternalImageId() r=jrmuizel
sotaro <sotaro.ikeda.g@gmail.com>
parents: 352068
diff changeset
  1138
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1139
bool GPUProcessManager::AllocateAndConnectLayerTreeId(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1140
    PCompositorBridgeChild* aCompositorBridge, base::ProcessId aOtherPid,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1141
    LayersId* aOutLayersId, CompositorOptions* aOutCompositorOptions) {
409886
5d9f32557d7740c7c30f7bc6057c4de0c294d828 Bug 1448490 - Make the layers id a struct instead of a uint64_t. r=mattwoodrow
Kartikaya Gupta <kgupta@mozilla.com>
parents: 408582
diff changeset
  1142
  LayersId layersId = AllocateLayerTreeId();
351067
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1143
  *aOutLayersId = layersId;
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1144
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1145
  if (!mGPUChild || !aCompositorBridge) {
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1146
    // If we're not remoting to another process, or there is no compositor,
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1147
    // then we'll send at most one message. In this case we can just keep
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1148
    // the old behavior of making sure the mapping occurs, and maybe sending
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1149
    // a creation notification.
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1150
    MapLayerTreeId(layersId, aOtherPid);
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1151
    if (!aCompositorBridge) {
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1152
      return false;
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1153
    }
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1154
    return aCompositorBridge->SendNotifyChildCreated(layersId,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1155
                                                     aOutCompositorOptions);
351067
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1156
  }
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1157
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1158
  // Use the combined message path.
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1159
  LayerTreeOwnerTracker::Get()->Map(layersId, aOtherPid);
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1160
  return aCompositorBridge->SendMapAndNotifyChildCreated(layersId, aOtherPid,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1161
                                                         aOutCompositorOptions);
351067
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1162
}
599e7c3933217e0dfd66403f40c4b8a4c8b31224 When using the GPU process, combine layer ownership and window mapping into a single IPC message. (bug 1350660 part 1, r=rhunt, r=billm)
David Anderson <dvander@alliedmods.net>
parents: 351066
diff changeset
  1163
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1164
void GPUProcessManager::EnsureVsyncIOThread() {
305740
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
  1165
  if (mVsyncIOThread) {
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
  1166
    return;
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
  1167
  }
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
  1168
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
  1169
  mVsyncIOThread = new VsyncIOThreadHolder();
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
  1170
  MOZ_RELEASE_ASSERT(mVsyncIOThread->Start());
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
  1171
}
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
  1172
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1173
void GPUProcessManager::ShutdownVsyncIOThread() { mVsyncIOThread = nullptr; }
305740
de2f89a5b4c3f821c37b230ef99dffa0b7325474 Add a top-level protocol for sending vsync messages to the GPU process. (bug 1285625 part 1, r=billm)
David Anderson <danderson@mozilla.com>
parents: 305340
diff changeset
  1174
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1175
void GPUProcessManager::RegisterRemoteProcessSession(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1176
    RemoteCompositorSession* aSession) {
314601
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
  1177
  mRemoteSessions.AppendElement(aSession);
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
  1178
}
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
  1179
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1180
void GPUProcessManager::UnregisterRemoteProcessSession(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1181
    RemoteCompositorSession* aSession) {
314601
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
  1182
  mRemoteSessions.RemoveElement(aSession);
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
  1183
}
5ac08fb77360da01e694dd3fb5fef07a64173298 Recreate widget compositors when the GPU process dies. (bug 1300936 part 2, r=mattwoodrow)
David Anderson <danderson@mozilla.com>
parents: 314600
diff changeset
  1184
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1185
void GPUProcessManager::RegisterInProcessSession(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1186
    InProcessCompositorSession* aSession) {
364295
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
  1187
  mInProcessSessions.AppendElement(aSession);
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
  1188
}
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
  1189
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1190
void GPUProcessManager::UnregisterInProcessSession(
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1191
    InProcessCompositorSession* aSession) {
364295
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
  1192
  mInProcessSessions.RemoveElement(aSession);
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
  1193
}
db5cc36763c1dff6c285011f30ded88304ca42b9 Bug 1274663 - Expose API to trigger device reset. r=dvander
domfarolino@gmail.com <domfarolino@gmail.com>
parents: 364055
diff changeset
  1194
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1195
void GPUProcessManager::AddListener(GPUProcessListener* aListener) {
314602
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
  1196
  mListeners.AppendElement(aListener);
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
  1197
}
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
  1198
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1199
void GPUProcessManager::RemoveListener(GPUProcessListener* aListener) {
314602
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
  1200
  mListeners.RemoveElement(aListener);
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
  1201
}
9a6f5fac405ffd3ab59163bf4c5ec866a1bb142b Recreate content compositor endpoints when the GPU process dies. (bug 1300936 part 3, r=mattwoodrow,billm)
David Anderson <danderson@mozilla.com>
parents: 314601
diff changeset
  1202
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1203
bool GPUProcessManager::NotifyGpuObservers(const char* aTopic) {
350455
50907f304e247c56192bdd4af58159b4cdab46b8 Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
vincentliu <vliu@mozilla.com>
parents: 348222
diff changeset
  1204
  if (!EnsureGPUReady()) {
318158
6fba47ac1541b9110be41ae32fff637f973f550e Bug 1275314 - Allow flushing in-progress checkerboard reports in the GPU process as well. r=dvander
Kartikaya Gupta <kgupta@mozilla.com>
parents: 318134
diff changeset
  1205
    return false;
6fba47ac1541b9110be41ae32fff637f973f550e Bug 1275314 - Allow flushing in-progress checkerboard reports in the GPU process as well. r=dvander
Kartikaya Gupta <kgupta@mozilla.com>
parents: 318134
diff changeset
  1206
  }
6fba47ac1541b9110be41ae32fff637f973f550e Bug 1275314 - Allow flushing in-progress checkerboard reports in the GPU process as well. r=dvander
Kartikaya Gupta <kgupta@mozilla.com>
parents: 318134
diff changeset
  1207
  nsCString topic(aTopic);
6fba47ac1541b9110be41ae32fff637f973f550e Bug 1275314 - Allow flushing in-progress checkerboard reports in the GPU process as well. r=dvander
Kartikaya Gupta <kgupta@mozilla.com>
parents: 318134
diff changeset
  1208
  mGPUChild->SendNotifyGpuObservers(topic);
6fba47ac1541b9110be41ae32fff637f973f550e Bug 1275314 - Allow flushing in-progress checkerboard reports in the GPU process as well. r=dvander
Kartikaya Gupta <kgupta@mozilla.com>
parents: 318134
diff changeset
  1209
  return true;
6fba47ac1541b9110be41ae32fff637f973f550e Bug 1275314 - Allow flushing in-progress checkerboard reports in the GPU process as well. r=dvander
Kartikaya Gupta <kgupta@mozilla.com>
parents: 318134
diff changeset
  1210
}
6fba47ac1541b9110be41ae32fff637f973f550e Bug 1275314 - Allow flushing in-progress checkerboard reports in the GPU process as well. r=dvander
Kartikaya Gupta <kgupta@mozilla.com>
parents: 318134
diff changeset
  1211
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1212
class GPUMemoryReporter : public MemoryReportingProcess {
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1213
 public:
331353
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1214
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GPUMemoryReporter, override)
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1215
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1216
  bool IsAlive() const override {
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1217
    if (GPUProcessManager* gpm = GPUProcessManager::Get()) {
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1218
      return !!gpm->GetGPUChild();
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1219
    }
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1220
    return false;
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1221
  }
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1222
522159
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
  1223
  bool SendRequestMemoryReport(
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
  1224
      const uint32_t& aGeneration, const bool& aAnonymize,
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
  1225
      const bool& aMinimizeMemoryUsage,
6e4528519a84ec3e4bb88c28ceaad7514a83ae1b Bug 1627482 - Fix non-unified build errors in gfx/ipc. r=tnikkel
Botond Ballo <botond@mozilla.com>
parents: 514406
diff changeset
  1226
      const Maybe<ipc::FileDescriptor>& aDMDFile) override {
331353
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1227
    GPUChild* child = GetChild();
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1228
    if (!child) {
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1229
      return false;
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1230
    }
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1231
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1232
    return child->SendRequestMemoryReport(aGeneration, aAnonymize,
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1233
                                          aMinimizeMemoryUsage, aDMDFile);
331353
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1234
  }
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1235
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1236
  int32_t Pid() const override {
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1237
    if (GPUChild* child = GetChild()) {
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1238
      return (int32_t)child->OtherPid();
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1239
    }
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1240
    return 0;
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1241
  }
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1242
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1243
 private:
331353
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1244
  GPUChild* GetChild() const {
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1245
    if (GPUProcessManager* gpm = GPUProcessManager::Get()) {
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1246
      if (GPUChild* child = gpm->GetGPUChild()) {
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1247
        return child;
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1248
      }
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1249
    }
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1250
    return nullptr;
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1251
  }
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1252
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1253
 protected:
331353
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1254
  ~GPUMemoryReporter() = default;
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1255
};
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1256
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1257
RefPtr<MemoryReportingProcess> GPUProcessManager::GetProcessMemoryReporter() {
350455
50907f304e247c56192bdd4af58159b4cdab46b8 Bug 1314543 - Make EnsureGPUReady() returns bool to make sure GPU process is readay. r=dvander
vincentliu <vliu@mozilla.com>
parents: 348222
diff changeset
  1258
  if (!EnsureGPUReady()) {
331353
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1259
    return nullptr;
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1260
  }
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1261
  return new GPUMemoryReporter();
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1262
}
ed89028b70a9ab00e118a847dc7f836cda135a55 Add memory reporting message support to PGPU. (bug 1321492 part 6, r=rhunt, r=erahm)
David Anderson <danderson@mozilla.com>
parents: 330452
diff changeset
  1263
448947
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1264
}  // namespace gfx
6f3709b3878117466168c40affa7bca0b60cf75b Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
Sylvestre Ledru <sledru@mozilla.com>
parents: 444793
diff changeset
  1265
}  // namespace mozilla