在VS代码中调试由电子产生的子进程(Debugging child process spawned by electron in VS code)
我正在使用webpack在typescript中构建一个电子应用程序,我遇到了以下vscode调试问题:
信息:主进程通过调用
fork('./dist/child', [], {execArgv: ['--debug-brk=3001']})
生成子进程。 我的launch.json
如下所示:{ "name": "Debug child process", "type": "node", "request": "attach", "address": "localhost", "port": 3001 }
脚步:
- 我在终端启动了我的电子应用程序
- 点击F5启动vscode调试器
正如预期的那样,它在我的webpack构建的第一行中为子进程代码打破了一次(由于
debug-brk
)。 这允许我在我的打字稿源中使用调试器注册其他断点。
- 正如预期的那样,一旦继续,vscode会在我的ts源中很好地击中那些断点。 好。
问题:如果我现在重新启动调试器(没有任何源更改或注册新断点)...
构建中的初始断点未被命中
我手动添加的断点被标记为忽略( 断点被忽略,因为找不到生成的代码(源映射问题?)。 )
此时我添加的任何新断点也会被标记为忽略。
我意识到Attach的调试与Launch的调试不同,并且需要一个
debug-brk
fork强制执行的初始中断,以便为连接的节点进程注册断点。问:但是,我想在调试过程中改进的是,调试器的简单重启不足以重新注册一些新的(或旧的)断点。 我必须完全退出我的应用程序并再次启动它, 然后在重新启动时调试器将再次停止在我的构建的第一行并识别我在该阶段添加的断点。
有没有人可以建议改善这种调试体验? 与启动调试会话相比,我不介意一些额外的步骤,但是必须手动退出并启动我的应用程序只是为了调试它有点麻烦,并且实际上在控制台中实际调试几乎更可取...
谢谢你的建议!
I am building an electron app in typescript with webpack, and I am running into the following vscode debugging problem:
Info: The main process spawns a child process by calling
fork('./dist/child', [], {execArgv: ['--debug-brk=3001']})
. Mylaunch.json
looks as follows:{ "name": "Debug child process", "type": "node", "request": "attach", "address": "localhost", "port": 3001 }
Steps:
- I launch my electron app in a terminal
- hit F5 to launch the vscode debugger
As expected, it hits a break at the first line of my webpack build for the child process code (due to
debug-brk
). This allows me to register additional breakpoints with the debugger in my typescript source.
- as expected, upon continuing, vscode hits those breakpoints nicely within my ts source. Good.
Problem: If I now restart the debugger (without any source changes or registering new breakpoints)...
The initial breakpoint in the build is not hit
My manually added breakpoints are marked ignored (Breakpoint ignored because generated code not found (source map problem?).)
Any new breakpoint I add at this point is also marked ignored.
I realize that debugging by Attach is different from debugging by Launch, and that the initial break enforced by a
debug-brk
fork is needed to give one the opportunity to register breakpoints for a node process that is attached to.Question: However, what I would like to improve in my debugging experience is that a simple restart of the debugger is not enough to re-register some new (or old) breakpoints. I have to entirely exit my app and start it again, before the debugger upon restart will again halt at the first line of my build and recognize breakpoints I add at that stage.
Is there a way anybody could recommend to improve this debug experience? I don't mind some extra steps as compared to a Launch debugging session, but having to manually quit and start my app just to debug it is a bit cumbersome, and makes actually debugging in the console almost more preferable...
Thanks for any advise!
原文:https://stackoverflow.com/questions/42495365
最满意答案
使用此代码
-(void)playMovieFinished:(NSNotification*)theNotification { [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; [moviePlayer stop]; // Change Segue ID Here [self performSegueWithIdentifier:@"VC_5" sender:self]; }
use this code
-(void)playMovieFinished:(NSNotification*)theNotification { [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; [moviePlayer stop]; // Change Segue ID Here [self performSegueWithIdentifier:@"VC_5" sender:self]; }
相关问答
更多-
MPMoviePlayer在设置为MPMovieRepeatModeOne时不会重复(MPMoviePlayer does not repeat when set to MPMovieRepeatModeOne)[2022-03-14]
我发现了它不重复的原因。 在我开始电影之后,我开始了一些内存密集型进程,不幸的是,对于我来说,我在主线程中发生了很多事情,当电影结束时,没有足够的内存可供重复使用。 瘸。 所以代码没有问题。 现在我将探索使用其他线程进行某些过程,以便在电影的主线上腾出空间来重复。 I have discovered the reason why it is not repeating. After I start the movie, I start a number of memory intensive process ... -
最后通过在moviePlayerPlayBackDidFinish添加其他代码解决了我的问题: self.navigationController?.popViewControllerAnimated(true) 经过大量研究,我从这里找到了解决方案: dismissViewControllerAnimated()不会解除视图控制器 Finally solved my issue by adding the additional code in moviePlayerPlayBackDidFinish: ...
-
我在这里已经回答了这个问题,代码是:将方向改回肖像 你有一个支持所有方向的应用程序 ,一个只支持肖像的主视图控制器 ,以及一个支持所有方向的子类 MPMoviePlayerController (或者全部,但是颠倒,或只有横向,或任何你想要的......)。 I have answered this here, with code: Change Orientation back to Portrait You have an app that supports all orientations, a ma ...
-
我的问题解决了,我将解释我迄今为止所做的。 当我找不到这种行为的解决方案/解释(我发现它很奇怪)时,我开始做很多很多的日志记录,所以我注意到当我记录我总是获得的当前位置(在iOS 5.1中) currentPlaybackTime = nan 但在iOS 5中,我获得了0.00000的正常值 所以我做了一个计时器(重复自己)每次记录当前时间 ,所以我注意到它在一段时间后从nan变为0.00000 我所做的结论是,在设置PlaybackTime之前,我需要等一下(不明白为什么),等待1 毫秒 (1/10 ...
-
如何解雇MPMoviePlayer?(how to dismiss MPMoviePlayer ? properly from one ViewController to another)[2023-09-08]
使用此代码 -(void)playMovieFinished:(NSNotification*)theNotification { [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; [moviePlayer stop]; // Change Segue ... -
流媒体MPMoviePlayer:叠加按钮显示得太早(Streaming MPMoviePlayer: overlay button showing up too early)[2023-08-08]
这几乎直接来自MoviePlayer示例项目,其中overlayView是您定义的视图。 NSArray *windows = [[UIApplication sharedApplication] windows]; if ([windows count] > 1) { // Locate the movie player window UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow]; ... -
我从来没有得到self.navigationController.parentViewController工作广告,但这对我self.navigationController.parentViewController : NSArray *viewControllerArray = [self.navigationController viewControllers]; int parentViewControllerIndex = [viewControllerArray count] - 2; [[vi ...
-
我想我看到了你的问题。 您在分配之前释放了player 。 基本上,编译器第一次浏览代码时,它会看到player获得保留计数-1(因为release调用),然后在分配时再次上升到0(因为new调用)。 因此,当您第一次尝试设置任何属性时,没有对象设置属性( player永远不会有保留计数为1)。 你应该做的是检查player的存在,只有它已经存在,然后你释放它。 尝试对makePlayer方法进行此更改: - (void) makePlayer { if (player != nil) { [playe ...
-
可能问题不是那么清楚......但是如果你想拥有一个播放器的2个实例,一起播放相同的剪辑,你需要有2个AVPlayer实例。 这是我开始的地方: http://iosguy.com/2012/01/11/multiple-video-playback-on-ios/ 很清楚 Probably the question was not that clear… But if you want to have 2 instance of a player, playing together the same cl ...
-
iOS 9中的MPMoviePlayer(MPMoviePlayer in iOS 9)[2022-04-12]
AVPlayerViewController是UIViewController的子类。 因此,不要使用常规视图控制器创建自定义电影播放器控制器,如下所示: 不要子类化AVPlayerViewController。 不支持覆盖此类的方法,并导致未定义的行为。 试试这样: import UIKit import AVKit import AVFoundation class MoviePlayerViewController: AVPlayerViewController { override func ...