3
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
- import { ipcRenderer } from 'electron' ;
6
+ import { CrashReporterStartOptions , ipcRenderer } from 'electron' ;
7
+ import { join } from 'path' ;
7
8
import { CancellationToken , CancellationTokenSource } from 'vs/base/common/cancellation' ;
8
9
import { Emitter } from 'vs/base/common/event' ;
9
10
import { Disposable } from 'vs/base/common/lifecycle' ;
10
11
import { FileAccess } from 'vs/base/common/network' ;
11
- import { generateUuid } from 'vs/base/common/uuid' ;
12
+ import { isLinux } from 'vs/base/common/platform' ;
13
+ import { generateUuid , isUUID } from 'vs/base/common/uuid' ;
14
+ import { INativeEnvironmentService } from 'vs/platform/environment/common/environment' ;
12
15
import { ILogService } from 'vs/platform/log/common/log' ;
16
+ import { IProductService } from 'vs/platform/product/common/productService' ;
13
17
import { hash , IOnDidTerminateSharedProcessWorkerProcess , ISharedProcessWorkerConfiguration , ISharedProcessWorkerProcessExit , ISharedProcessWorkerService } from 'vs/platform/sharedProcess/common/sharedProcessWorkerService' ;
14
- import { SharedProcessWorkerMessages , ISharedProcessToWorkerMessage , IWorkerToSharedProcessMessage } from 'vs/platform/sharedProcess/electron-browser/sharedProcessWorker' ;
18
+ import { SharedProcessWorkerMessages , ISharedProcessToWorkerMessage , IWorkerToSharedProcessMessage , ISharedProcessWorkerEnvironment } from 'vs/platform/sharedProcess/electron-browser/sharedProcessWorker' ;
15
19
16
20
export class SharedProcessWorkerService implements ISharedProcessWorkerService {
17
21
@@ -23,7 +27,9 @@ export class SharedProcessWorkerService implements ISharedProcessWorkerService {
23
27
private readonly processResolvers = new Map < number /* process configuration hash */ , ( process : IOnDidTerminateSharedProcessWorkerProcess ) => void > ( ) ;
24
28
25
29
constructor (
26
- @ILogService private readonly logService : ILogService
30
+ @ILogService private readonly logService : ILogService ,
31
+ @IProductService private readonly productService : IProductService ,
32
+ @INativeEnvironmentService private readonly environmentService : INativeEnvironmentService
27
33
) {
28
34
}
29
35
@@ -117,7 +123,7 @@ export class SharedProcessWorkerService implements ISharedProcessWorkerService {
117
123
if ( ! webWorkerPromise ) {
118
124
this . logService . trace ( `SharedProcess: creating new web worker (${ configuration . process . moduleId } )` ) ;
119
125
120
- const sharedProcessWorker = new SharedProcessWebWorker ( configuration . process . type , this . logService ) ;
126
+ const sharedProcessWorker = new SharedProcessWebWorker ( configuration . process . type , this . logService , this . productService , this . environmentService ) ;
121
127
webWorkerPromise = sharedProcessWorker . init ( ) ;
122
128
123
129
// Make sure to run through our normal `disposeWorker` call
@@ -156,7 +162,9 @@ class SharedProcessWebWorker extends Disposable {
156
162
157
163
constructor (
158
164
private readonly type : string ,
159
- private readonly logService : ILogService
165
+ private readonly logService : ILogService ,
166
+ private readonly productService : IProductService ,
167
+ private readonly environmentService : INativeEnvironmentService
160
168
) {
161
169
super ( ) ;
162
170
}
@@ -280,14 +288,47 @@ class SharedProcessWebWorker extends Disposable {
280
288
const workerMessage : ISharedProcessToWorkerMessage = {
281
289
id : SharedProcessWorkerMessages . Spawn ,
282
290
configuration,
283
- environment : {
284
- bootstrapPath : FileAccess . asFileUri ( 'bootstrap-fork' , require ) . fsPath
285
- }
291
+ environment : this . getSharedProcessWorkerEnvironment ( )
286
292
} ;
287
293
288
294
return this . send ( workerMessage , token , port ) ;
289
295
}
290
296
297
+ private getSharedProcessWorkerEnvironment ( ) : ISharedProcessWorkerEnvironment {
298
+ const sharedProcessWorkerEnvironment = {
299
+ bootstrapPath : FileAccess . asFileUri ( 'bootstrap-fork' , require ) . fsPath ,
300
+ env : Object . create ( null )
301
+ } ;
302
+
303
+ // Crash reporter support
304
+ // TODO@bpasero TODO@deepak1556 remove once we updated to Electron 15
305
+ if ( isLinux ) {
306
+ const crashReporterStartOptions : CrashReporterStartOptions = {
307
+ companyName : this . productService . crashReporter ?. companyName || 'Microsoft' ,
308
+ productName : this . productService . crashReporter ?. productName || this . productService . nameShort ,
309
+ submitURL : '' ,
310
+ uploadToServer : false
311
+ } ;
312
+
313
+ const crashReporterId = this . environmentService . args [ 'crash-reporter-id' ] ; // crashReporterId is set by the main process only when crash reporting is enabled by the user.
314
+ const appcenter = this . productService . appCenter ;
315
+ const uploadCrashesToServer = ! this . environmentService . args [ 'crash-reporter-directory' ] ; // only upload unless --crash-reporter-directory is provided
316
+ if ( uploadCrashesToServer && appcenter && crashReporterId && isUUID ( crashReporterId ) ) {
317
+ const submitURL = appcenter [ `linux-x64` ] ;
318
+ crashReporterStartOptions . submitURL = submitURL . concat ( '&uid=' , crashReporterId , '&iid=' , crashReporterId , '&sid=' , crashReporterId ) ;
319
+ crashReporterStartOptions . uploadToServer = true ;
320
+ }
321
+ // In the upload to server case, there is a bug in electron that creates client_id file in the current
322
+ // working directory. Setting the env BREAKPAD_DUMP_LOCATION will force electron to create the file in that location,
323
+ // For https://github.com/microsoft/vscode/issues/105743
324
+ const extHostCrashDirectory = this . environmentService . args [ 'crash-reporter-directory' ] || this . environmentService . userDataPath ;
325
+ sharedProcessWorkerEnvironment . env . BREAKPAD_DUMP_LOCATION = join ( extHostCrashDirectory , `Parcel Watcher Crash Reports` ) ;
326
+ sharedProcessWorkerEnvironment . env . VSCODE_CRASH_REPORTER_START_OPTIONS = JSON . stringify ( crashReporterStartOptions ) ;
327
+ }
328
+
329
+ return sharedProcessWorkerEnvironment ;
330
+ }
331
+
291
332
terminate ( configuration : ISharedProcessWorkerConfiguration , token : CancellationToken ) : Promise < void > {
292
333
const workerMessage : ISharedProcessToWorkerMessage = {
293
334
id : SharedProcessWorkerMessages . Terminate ,
0 commit comments