From 7b3e998cc6bf9a8ec8be45fe5b0ca43081be31bb Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 Feb 2017 13:20:38 -0800 Subject: [PATCH] Use content tracing after app ready --- docs/api/content-tracing.md | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/api/content-tracing.md b/docs/api/content-tracing.md index a1c76d880701..6160ef8aaafc 100644 --- a/docs/api/content-tracing.md +++ b/docs/api/content-tracing.md @@ -9,22 +9,28 @@ This module does not include a web interface so you need to open `chrome://tracing/` in a Chrome browser and load the generated file to view the result. +**Note:** You should not use this module until the `ready` event of the app +module is emitted. + + ```javascript -const {contentTracing} = require('electron') +const {app, contentTracing} = require('electron') -const options = { - categoryFilter: '*', - traceOptions: 'record-until-full,enable-sampling' -} +app.on('ready', () => { + const options = { + categoryFilter: '*', + traceOptions: 'record-until-full,enable-sampling' + } -contentTracing.startRecording(options, () => { - console.log('Tracing started') + contentTracing.startRecording(options, () => { + console.log('Tracing started') - setTimeout(() => { - contentTracing.stopRecording('', (path) => { - console.log('Tracing data recorded to ' + path) - }) - }, 5000) + setTimeout(() => { + contentTracing.stopRecording('', (path) => { + console.log('Tracing data recorded to ' + path) + }) + }, 5000) + }) }) ```