GPUProcessHost must obtain a reference to the GPU process'
CompositorSurfaceManager, which requires a round-trip to the IPC
launcher thread in order to interact with GeckoProcessManager.
Currently this is achieved using a synchronous task, which has the
downside of blocking the main thread during startup.
This patch attempts to obtain the reference asynchronously, by
scheduling a task to run on the IPC launcher thread to obtain the
reference from GeckoSurfaceManager, then another back on the main
thread to initialize GPUProcessHost's member variable.
If GPUProcessHost::WaitForLaunch() is called prior to the async
initialization completing, we fall back to the synchronous task
approach.
Differential Revision: https://phabricator.services.mozilla.com/D272309
In the case where the GPU process channel is connected asynchronously
we unfortunately send a synchronous GPUChild::SendGetDeviceStatus()
message immediately afterwards. This is a regression from bug 1993758,
which added a call to GPUChild::EnsureGPUReady() to
GPUProcessManager::OnProcessLaunchComplete(). Ideally we'd like to
avoid using this synchronous message unless required, and instead
allow time for the asynchronous Init()/InitComplete() callback to
complete.
This patch achieves just that by delaying calling the listener's
OnProcessLaunchComplete() callback until after the post-connection
initialization is complete, rather than immediately after the channel
has connected. This means that by the time the GPUProcessManager calls
EnsureGPUReady(), initialization will have already completed.
A new "Connected" LaunchPhase is added prior to "Complete", indicating
that the channel has been connected but post-connection initialization
has not yet completed. Upon connection we start asynchronous
initialization as before, but now track its completion using a Promise
and call OnProcessLaunchComplete when that resolves.
As before, if GPUProcessManager requires the launch to complete
synchronously it calls GPUProcessHost::WaitForLaunch(). This will now
additionally ensure initialization has completed prior to returning by
sending the synchronous SendGetDeviceData message.
Differential Revision: https://phabricator.services.mozilla.com/D272308
To ensure tasks dispatched between threads in GPUProcessHost do not
run after the GPU process has been destroyed we currently use
ipc::TaskFactory, which allows us to revoke pending tasks on
shutdown.
This patch switches to using a refcounted "live token" and checking
whether the process is still live before doing any work in the
task. This is the same approach used in the RDD and Utility processes.
This should have no functional change, but will allow subsequent
patches to ensure the process is still live when executing promise
callbacks.
Additionally removes the unused OnChannelErrorTask() function.
Differential Revision: https://phabricator.services.mozilla.com/D272307
This reverts commit 8b91e5ff50.
Revert "Bug 1999645 - Avoid synchronous GPUChild::SendGetDeviceStatus after GPU process channel is connected asynchronously. r=aosmond"
This reverts commit b535b81d7c.
Revert "Bug 1999645 - Use live token instead of ipc::TaskFactory in GPUProcessHost. r=aosmond"
This reverts commit 6d17a0731b.
GPUProcessHost must obtain a reference to the GPU process'
CompositorSurfaceManager, which requires a round-trip to the IPC
launcher thread in order to interact with GeckoProcessManager.
Currently this is achieved using a synchronous task, which has the
downside of blocking the main thread during startup.
This patch attempts to obtain the reference asynchronously, by
scheduling a task to run on the IPC launcher thread to obtain the
reference from GeckoSurfaceManager, then another back on the main
thread to initialize GPUProcessHost's member variable.
If GPUProcessHost::WaitForLaunch() is called prior to the async
initialization completing, we fall back to the synchronous task
approach.
Differential Revision: https://phabricator.services.mozilla.com/D272309
In the case where the GPU process channel is connected asynchronously
we unfortunately send a synchronous GPUChild::SendGetDeviceStatus()
message immediately afterwards. This is a regression from bug 1993758,
which added a call to GPUChild::EnsureGPUReady() to
GPUProcessManager::OnProcessLaunchComplete(). Ideally we'd like to
avoid using this synchronous message unless required, and instead
allow time for the asynchronous Init()/InitComplete() callback to
complete.
This patch achieves just that by delaying calling the listener's
OnProcessLaunchComplete() callback until after the post-connection
initialization is complete, rather than immediately after the channel
has connected. This means that by the time the GPUProcessManager calls
EnsureGPUReady(), initialization will have already completed.
A new "Connected" LaunchPhase is added prior to "Complete", indicating
that the channel has been connected but post-connection initialization
has not yet completed. Upon connection we start asynchronous
initialization as before, but now track its completion using a Promise
and call OnProcessLaunchComplete when that resolves.
As before, if GPUProcessManager requires the launch to complete
synchronously it calls GPUProcessHost::WaitForLaunch(). This will now
additionally ensure initialization has completed prior to returning by
sending the synchronous SendGetDeviceData message.
Differential Revision: https://phabricator.services.mozilla.com/D272308
To ensure tasks dispatched between threads in GPUProcessHost do not
run after the GPU process has been destroyed we currently use
ipc::TaskFactory, which allows us to revoke pending tasks on
shutdown.
This patch switches to using a refcounted "live token" and checking
whether the process is still live before doing any work in the
task. This is the same approach used in the RDD and Utility processes.
This should have no functional change, but will allow subsequent
patches to ensure the process is still live when executing promise
callbacks.
Additionally removes the unused OnChannelErrorTask() function.
Differential Revision: https://phabricator.services.mozilla.com/D272307
GPUProcessHost must obtain a reference to the GPU process'
CompositorSurfaceManager, which requires a round-trip to the IPC
launcher thread in order to interact with GeckoProcessManager.
Currently this is achieved using a synchronous task, which has the
downside of blocking the main thread during startup.
This patch attempts to obtain the reference asynchronously, by
scheduling a task to run on the IPC launcher thread to obtain the
reference from GeckoSurfaceManager, then another back on the main
thread to initialize GPUProcessHost's member variable.
If GPUProcessHost::WaitForLaunch() is called prior to the async
initialization completing, we fall back to the synchronous task
approach.
Differential Revision: https://phabricator.services.mozilla.com/D272309
In the case where the GPU process channel is connected asynchronously
we unfortunately send a synchronous GPUChild::SendGetDeviceStatus()
message immediately afterwards. This is a regression from bug 1993758,
which added a call to GPUChild::EnsureGPUReady() to
GPUProcessManager::OnProcessLaunchComplete(). Ideally we'd like to
avoid using this synchronous message unless required, and instead
allow time for the asynchronous Init()/InitComplete() callback to
complete.
This patch achieves just that by delaying calling the listener's
OnProcessLaunchComplete() callback until after the post-connection
initialization is complete, rather than immediately after the channel
has connected. This means that by the time the GPUProcessManager calls
EnsureGPUReady(), initialization will have already completed.
A new "Connected" LaunchPhase is added prior to "Complete", indicating
that the channel has been connected but post-connection initialization
has not yet completed. Upon connection we start asynchronous
initialization as before, but now track its completion using a Promise
and call OnProcessLaunchComplete when that resolves.
As before, if GPUProcessManager requires the launch to complete
synchronously it calls GPUProcessHost::WaitForLaunch(). This will now
additionally ensure initialization has completed prior to returning by
sending the synchronous SendGetDeviceData message.
Differential Revision: https://phabricator.services.mozilla.com/D272308
To ensure tasks dispatched between threads in GPUProcessHost do not
run after the GPU process has been destroyed we currently use
ipc::TaskFactory, which allows us to revoke pending tasks on
shutdown.
This patch switches to using a refcounted "live token" and checking
whether the process is still live before doing any work in the
task. This is the same approach used in the RDD and Utility processes.
This should have no functional change, but will allow subsequent
patches to ensure the process is still live when executing promise
callbacks.
Additionally removes the unused OnChannelErrorTask() function.
Differential Revision: https://phabricator.services.mozilla.com/D272307
Add a sandbox profile for the macOS GPU process (which is pref'd off at this
time). By default, the sandbox will be enabled whenever the GPU process is
enabled.
The sandbox is enabled by the integer pref `security.sandbox.gpu.level` already
used on Windows. Any value > 0 enables the sandbox. For now, the implementation
does not have different levels and is either on or off.
The environment variable MOZ_SANDBOX_GPU_LOGGING can be used to enable sandbox
violation logging for only the GPU process in macOS log viewing tools (not
Firefox logs).
Includes a minimal sandboxing test exercised on debug builds to validate that
the sandbox gets started for the GPU process.
Differential Revision: https://phabricator.services.mozilla.com/D264685
This patch implements the majority of the public interface for the new IPC
handle passing design.
The rough design is an expansion of `geckoargs` to allow passing
`UniqueFileHandle` arguments to child processes. This replaces the existing
extra options array to make the list of files explicit.
This currently just replaces things which were already passed this way on the
command line from outside of GeckoChildProcessHost. Note that this does not
migrate callers which were not already passing file handles using geckoargs,
and does not implement the actual OS-level support for passing arguments this
way.
Differential Revision: https://phabricator.services.mozilla.com/D221371
This patch implements the majority of the public interface for the new IPC
handle passing design.
The rough design is an expansion of `geckoargs` to allow passing
`UniqueFileHandle` arguments to child processes. This replaces the existing
extra options array to make the list of files explicit.
This currently just replaces things which were already passed this way on the
command line from outside of GeckoChildProcessHost. Note that this does not
migrate callers which were not already passing file handles using geckoargs,
and does not implement the actual OS-level support for passing arguments this
way.
Differential Revision: https://phabricator.services.mozilla.com/D221371
Extend the sync IPC timeout mechanism in CompositorManagerChild to
additionally cover UiCompositorControllerChild. As
UiCompositorControllerChild runs on the Android UI thread, we ensure
GPUProcessManager::KillProcess dispatches to the gecko main thread.
Along with the previous patch in this series this should provide us
with crash reports when the Android UI thread is hung waiting for the
GPU process to reply.
Differential Revision: https://phabricator.services.mozilla.com/D202167
When sync IPC under the top-level PCompositorManager protocol does not
reply within a certain time threshold we purposefully kill the GPU
process. While this allows the user to recover from a stuck GPU
process, we have little visibility about the underlying cause.
This patch makes it so that we generate a paired minidump for the GPU
and parent processes prior to killing the GPU process in
GPUProcessHost::KillHard(). The implementation roughly follows the
equivalent for content processes in ContentParent::KillHard().
As the GPU process can be purposefully killed during normal operation,
and because generating minidumps can be expensive, we are careful to
only do so when the new argument aGenerateMinidump is true. We
additionally remove the aReason argument as it is unused (and
currently innacurate in some places).
As these minidumps may not automatically submitted we limit the
minidumps generation to twice per session in order to avoid
accumulating a large number of unsubmitted minidumps on disk.
Differential Revision: https://phabricator.services.mozilla.com/D202166
Extend the sync IPC timeout mechanism in CompositorManagerChild to
additionally cover UiCompositorControllerChild. As
UiCompositorControllerChild runs on the Android UI thread, we ensure
GPUProcessManager::KillProcess dispatches to the gecko main thread.
Along with the previous patch in this series this should provide us
with crash reports when the Android UI thread is hung waiting for the
GPU process to reply.
Differential Revision: https://phabricator.services.mozilla.com/D202167
When sync IPC under the top-level PCompositorManager protocol does not
reply within a certain time threshold we purposefully kill the GPU
process. While this allows the user to recover from a stuck GPU
process, we have little visibility about the underlying cause.
This patch makes it so that we generate a paired minidump for the GPU
and parent processes prior to killing the GPU process in
GPUProcessHost::KillHard(). The implementation roughly follows the
equivalent for content processes in ContentParent::KillHard().
As the GPU process can be purposefully killed during normal operation,
and because generating minidumps can be expensive, we are careful to
only do so when the new argument aGenerateMinidump is true. We
additionally remove the aReason argument as it is unused (and
currently innacurate in some places).
As these minidumps may not automatically submitted we limit the
minidumps generation to twice per session in order to avoid
accumulating a large number of unsubmitted minidumps on disk.
Differential Revision: https://phabricator.services.mozilla.com/D202166
Extend the sync IPC timeout mechanism in CompositorManagerChild to
additionally cover UiCompositorControllerChild. As
UiCompositorControllerChild runs on the Android UI thread, we ensure
GPUProcessManager::KillProcess dispatches to the gecko main thread.
Along with the previous patch in this series this should provide us
with crash reports when the Android UI thread is hung waiting for the
GPU process to reply.
Differential Revision: https://phabricator.services.mozilla.com/D202167
When sync IPC under the top-level PCompositorManager protocol does not
reply within a certain time threshold we purposefully kill the GPU
process. While this allows the user to recover from a stuck GPU
process, we have little visibility about the underlying cause.
This patch makes it so that we generate a paired minidump for the GPU
and parent processes prior to killing the GPU process in
GPUProcessHost::KillHard(). The implementation roughly follows the
equivalent for content processes in ContentParent::KillHard().
As the GPU process can be purposefully killed during normal operation,
and because generating minidumps can be expensive, we are careful to
only do so when the new argument aGenerateMinidump is true. We
additionally remove the aReason argument as it is unused (and
currently innacurate in some places).
As these minidumps may not automatically submitted we limit the
minidumps generation to twice per session in order to avoid
accumulating a large number of unsubmitted minidumps on disk.
Differential Revision: https://phabricator.services.mozilla.com/D202166
Now that we've simplified the startup process somewhat, it is easier to clean
up IPC channel creation for NodeChannel connections. This stops having
GeckoChildProcessHost inherit from IPC::Channel::Listener, as it would never
receive most of the relevant callbacks, and instead implements the one callback
it would receive directly as a method on that type.
Differential Revision: https://phabricator.services.mozilla.com/D181282
This improves consistency with the child process case, and will make it easier
to attach additional state without needing to thread it through every child
process callsite manually.
Differential Revision: https://phabricator.services.mozilla.com/D153619
In the following patch we are going to change the signature of
ShouldSanitizePreference to take a Pref object. Pref is only
known to the Preferences compilation unit; so to keep this member
(whose signature will change) we would need to expose the Pref
class. However it will only be a forward declaration, one could
not construct a Pref object in e.g. the gtest.
It is simpler to just remove the member entirely and call
ShouldSanitizePreference unconditionally - the member was only
used for the gtest, and while the gtest will be less robust
because of this change, it will still do some testing.
Depends on D141419
Differential Revision: https://phabricator.services.mozilla.com/D141420
To do the correct thing in Preferences::SerializePreferences
(which is used during subprocess startup) we need to know if
the destination process is a web content process or not.
We add parameters to
SharedPreferenceSerializer::SerializeToSharedMemory that let
us figure that out.
In Preferences::SerializePreferences we fix the call to
aShouldSanitizeFn to pass the correct destination.
Depends on D141415
Differential Revision: https://phabricator.services.mozilla.com/D141416
This simplifies the number of negations needed,
and makes things easy to understand. I think
anyway; I know that without renaming it I made
several annoying-to-diagnose negation errors...
Depends on D141411
Differential Revision: https://phabricator.services.mozilla.com/D141412
dom/media/ipc/RDDProcessManager.cpp(320,21): error: comparison of integers of different signs: 'base::ProcessId' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
gpuProcessPid != -1 ? gpuProcessPid : base::GetCurrentProcId();
~~~~~~~~~~~~~ ^ ~~
dom/media/ipc/RDDProcessManager.cpp(332,21): error: comparison of integers of different signs: 'base::ProcessId' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
if (gpuProcessPid != -1) {
~~~~~~~~~~~~~ ^ ~~
gfx/layers/ipc/SharedSurfacesParent.cpp(360,38): error: comparison of integers of different signs: 'base::ProcessId' (aka 'unsigned long') and 'int' [-Werror,-Wsign-compare]
if (!gpm || gpm->GPUProcessPid() != -1) {
~~~~~~~~~~~~~~~~~~~~ ^ ~~
ipc/glue/MessageChannel.cpp(2145,13): error: comparison of integers of different signs: 'int32_t' (aka 'int') and 'const base::ProcessId' (aka 'const unsigned long') [-Werror,-Wsign-compare]
if (pid != base::kInvalidProcessId &&
~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~
Differential Revision: https://phabricator.services.mozilla.com/D144688
In the following patch we are going to change the signature of
ShouldSanitizePreference to take a Pref object. Pref is only
known to the Preferences compilation unit; so to keep this member
(whose signature will change) we would need to expose the Pref
class. However it will only be a forward declaration, one could
not construct a Pref object in e.g. the gtest.
It is simpler to just remove the member entirely and call
ShouldSanitizePreference unconditionally - the member was only
used for the gtest, and while the gtest will be less robust
because of this change, it will still do some testing.
Depends on D141419
Differential Revision: https://phabricator.services.mozilla.com/D141420
To do the correct thing in Preferences::SerializePreferences
(which is used during subprocess startup) we need to know if
the destination process is a web content process or not.
We add parameters to
SharedPreferenceSerializer::SerializeToSharedMemory that let
us figure that out.
In Preferences::SerializePreferences we fix the call to
aShouldSanitizeFn to pass the correct destination.
Depends on D141415
Differential Revision: https://phabricator.services.mozilla.com/D141416
This simplifies the number of negations needed,
and makes things easy to understand. I think
anyway; I know that without renaming it I made
several annoying-to-diagnose negation errors...
Depends on D141411
Differential Revision: https://phabricator.services.mozilla.com/D141412
In the following patch we are going to change the signature of
ShouldSanitizePreference to take a Pref object. Pref is only
known to the Preferences compilation unit; so to keep this member
(whose signature will change) we would need to expose the Pref
class. However it will only be a forward declaration, one could
not construct a Pref object in e.g. the gtest.
It is simpler to just remove the member entirely and call
ShouldSanitizePreference unconditionally - the member was only
used for the gtest, and while the gtest will be less robust
because of this change, it will still do some testing.
Depends on D141419
Differential Revision: https://phabricator.services.mozilla.com/D141420
To do the correct thing in Preferences::SerializePreferences
(which is used during subprocess startup) we need to know if
the destination process is a web content process or not.
We add parameters to
SharedPreferenceSerializer::SerializeToSharedMemory that let
us figure that out.
In Preferences::SerializePreferences we fix the call to
aShouldSanitizeFn to pass the correct destination.
Depends on D141415
Differential Revision: https://phabricator.services.mozilla.com/D141416
This simplifies the number of negations needed,
and makes things easy to understand. I think
anyway; I know that without renaming it I made
several annoying-to-diagnose negation errors...
Depends on D141411
Differential Revision: https://phabricator.services.mozilla.com/D141412
In the following patch we are going to change the signature of
ShouldSanitizePreference to take a Pref object. Pref is only
known to the Preferences compilation unit; so to keep this member
(whose signature will change) we would need to expose the Pref
class. However it will only be a forward declaration, one could
not construct a Pref object in e.g. the gtest.
It is simpler to just remove the member entirely and call
ShouldSanitizePreference unconditionally - the member was only
used for the gtest, and while the gtest will be less robust
because of this change, it will still do some testing.
Depends on D141419
Differential Revision: https://phabricator.services.mozilla.com/D141420
To do the correct thing in Preferences::SerializePreferences
(which is used during subprocess startup) we need to know if
the destination process is a web content process or not.
We add parameters to
SharedPreferenceSerializer::SerializeToSharedMemory that let
us figure that out.
In Preferences::SerializePreferences we fix the call to
aShouldSanitizeFn to pass the correct destination.
Depends on D141415
Differential Revision: https://phabricator.services.mozilla.com/D141416