LayerScope reads "gfx.layerscope.enabled" in the beginning of B2G process created. Which means we need to restart B2G if we want to dump layer image if this value is original false. It's more convenient if we can start and stop recording, without restart Chrome process, on demand.
Make sure the preferences are only ever accessed from the main thread.
This is a misunderstanding of the current code, I think. "gfx.layerscope.enabled" only controls whether the process listens on the port or not; this is just a security control, because there is no other security around getting the layerscope data (in other words, reading the screen). It does not control whether the data is being captured or streamed. There is no downside to running with "gfx.layerscope.enabled" set to "true", and this might not be a bad idea for a default for developer builds. All of the layerscope code is gated on the "gDebugConnected" variable, which is true only if something is actively connected to the port. If it's false, the "begin frame" and send-check functions just return, and no data gets captured. See http://dxr.mozilla.org/mozilla-central/source/gfx/layers/LayerScope.cpp#434 and http://dxr.mozilla.org/mozilla-central/source/gfx/layers/LayerScope.cpp#287 So starting and stopping is just a matter of connecting and disconnecting.