Author Topic: Voice Attack crashing  (Read 2052 times)

Darkcyde

  • Newbie
  • *
  • Posts: 6
Voice Attack crashing
« on: April 27, 2021, 12:36:45 PM »
Hi,

I use Voice Attack with the EDDI and bindED plugins, and after making a (somewhat simple) VA command, VA crashes randomly when the command is executed.

The VoiceAttackFault.txt has nothing in it (other than something from 3 years ago), but the EDDI log has an unhandled exception error that mentions VA, just before it does a clean shutdown from the crash.

Here's the last part from the error log:

2021-04-27T17:50:42 [Info] VoiceAttackPlugin:triggerVACommands Executed command ((EDDI ship targeted))
2021-04-27T17:50:42 [Info] VoiceAttackPlugin:triggerVACommands Executed command ((EDDI ship targeted))
2021-04-27T17:50:43 [Info] Logging:ExceptionHandler Reporting unhandled exception, anonymous ID 20c709fe-25a2-4ae4-91fd-7bf6051d42e5:System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at VoiceAttack.VA.()
   at VoiceAttack.VA.(String , Command2 )
   at VoiceAttack.VA.(Command2 , Process , Int32 , Boolean , Nullable`1 , Guid , Guid , List`1 , Command2 )
   at VoiceAttack.VA.†.()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
2021-04-27T17:50:43 [Info] EDDI:Stop EDDI 3.7.3 stopped
2021-04-27T17:50:43 [Info] EDDI:Start Starting keepalive for EDDP monitor
2021-04-27T17:50:43 [Info] EDDI:Start Starting keepalive for Status monitor
2021-04-27T17:50:43 [Info] EDDI:Start Started EDDN responder
2021-04-27T17:50:43 [Info] EDDI:Start Starting keepalive for Galnet monitor
2021-04-27T17:50:43 [Info] EDDI:Start Starting keepalive for Mission monitor
2021-04-27T17:50:43 [Info] EDDI:Start Starting keepalive for Journal monitor
2021-04-27T17:50:43 [Info] EDDI:Start Started Speech responder
2021-04-27T17:50:43 [Info] EDDI:Start Started Inara Responder
2021-04-27T17:50:43 [Info] EDDI:Start Started EDSM responder
2021-04-27T17:50:43 [Info] EDDI:Start Started VoiceAttack responder
2021-04-27T17:50:43 [Info] InaraResponder:Start Initialized Inara Responder
2021-04-27T17:50:44 [Info] DataProviderService:syncFromStarMapService EDSM sync completed

The command that is run when this happens, is a simple multi-part IF that checks some variables already set by EDDI, then does a keypress if they resolve to 'true', either an bindED variable key, or a default key if bindED is not set.  I do notice that the command looks like it is being run twice in the same second, when it is only being activated once, so I'm not sure if that has anything to do with it.  It only appears once in the log when it activates and doesn't crash.

Pause 0.1 seconds
Begin Condition : ([EDDI state eddi_context_target_module] Equals False AND [EDDI state eddi_context_stop_cycle] Is Less Than 2 AND [EDDI state eddi_context_target_wanted] Equals True)
    Begin Text Compare : [edCycleNextSubsystem] Has Been Set
        Press variable key(s) [edCycleNextSubsystem] and hold for 0.2 seconds and release
    Else
        Press Y key and hold for 0.2 seconds and release
    End Condition
End Condition


The thing is, I can run this command all day with nothing going wrong, then the next time I load up it will happen, then not again for hours.  It's so random, and I'm at a loss as to why.

I tried adding the 0.1 second pause at the start of the VA command, in case it was a timing issue, and I thought that had fixed it as I went two days without it happening.  However, I've tried to use it today, and it's happening again.

Can anyone help with this at all please?  Also, please bear in mind I am a complete VA noob, and only use the bare minimum of VA to get what I want done, so I don't know much about the more complex things about it. :P

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Voice Attack crashing
« Reply #1 on: April 27, 2021, 01:29:48 PM »
It could be a race condition, where two separate threads are trying to modify the same value at the same time.

Depending on how the timing works out, this can happen seemingly randomly.


Have you checked whether you have anything set up in the "EDDI" application that would cause a command or variable change to be triggered twice?

Have you contacted EDDI about this? Their developers are reportedly active on this Discord.

Darkcyde

  • Newbie
  • *
  • Posts: 6
Re: Voice Attack crashing
« Reply #2 on: April 28, 2021, 04:10:36 PM »
Hmm, I'm not sure, I wouldn't expect any of those variables to be changed twice at the same time...

There is an event in EDDI that gets triggered when you target a ship.  In that event I set the variables that are checked in the VA command.  The VA command gets triggered by EDDI at the same time (I believe) as it does in EDDI, hence why I put a 0.1 second delay in the command, to try to delay it running (although I'm not 100% sure this will have the effect I'm aiming for).  The command then gets Elite to select a subsystem of the target ship (the keypress), which in turn will again trigger the 'ship targeted' event in EDDI, and the command in VA.  The aim is to stop when a particular subsystem has been targeted.  This could go round and round if the subsystem isn't found, which is why I have certain variables to check so that it only cycles through a ships subsystems once, and stop before that if the correct subsystem is found.

Now, I can target NPC ships all day without any problems, but when I target my own ship (while in a buggy on a planet surface), then this random crash can occur.  I can't understand why it only seems to happen to my ship, as there is nothing different in the EDDI event that would be affected by that over an NPC ship.

I have contacted the devs of EDDI, giving them the error code and explaining it all to them too.  They said they think it's possibly not EDDI that's causing it, due to the mention of VA in the error and EDDI seems to do a clean shutdown afterwards.  So they suggested I ask for help here, to see what people here can suggest.

Do you think increasing the pause in VA could help?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Voice Attack crashing
« Reply #3 on: April 28, 2021, 04:28:19 PM »
Your command doesn't set anything, and the exception refers to an Insert operation, which would be adding data to a dictionary, not just reading from it, so it's more likely that the issue occurs at the point the Command.Execute() method runs, rather than the command itself, in which case adding a pause within the command would have no impact on that at all.

From what I can see in their source code, they're not passing any values to the command either, just a straight "ExecuteCommand()" call (they're using the old alias) without any parameters aside from the command name.

Darkcyde

  • Newbie
  • *
  • Posts: 6
Re: Voice Attack crashing
« Reply #4 on: April 29, 2021, 10:15:53 AM »
OK, so if the EDDI event, and the VA command, are both executing at the same time, could the event setting those variables used in the command, be the problem?  I guess technically the variables are being set (in EDDI) at the same moment they are trying to be read (in VA).

Sorry if I'm sounding a bit dumb, I really don't know VA very well at all.  :-[

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Voice Attack crashing
« Reply #5 on: April 29, 2021, 02:46:26 PM »
It's possible, but given that the exception refers to a method that takes a command object it's less likely, as setting variables would presumably not require a command to execute (unless that's how it's set up internally somehow).


Having a look through old forum topics, there was an issue quite a while back with duplicate command names causing this exception; which version of VoiceAttack are you running?

Do you have the "((EDDI ship targeted))" command in your profile more than once? Do you have any profiles included into the current one (perhaps as a global profile) that contain that command?

Darkcyde

  • Newbie
  • *
  • Posts: 6
Re: Voice Attack crashing
« Reply #6 on: April 29, 2021, 04:01:23 PM »
I'm using version 1.8.7.12 beta 64bit of Voice Attack.

I only have the one instance of the ((EDDI ship targeted)) command, and no other profiles included.

The variables that are set in the EDDI event, are ones I've created specifically for this functionality, so will only be set once the event script is executed.  They are EDDI 'state' variables, so that they persist until VA/EDDI is closed down, and are available to use in VA.  However, until the script is run for the first time, those variables are not set at all.

When the crash occurs, I hear the voice output from the EDDI event script.  In this case I have made it say "Your ship is clean" for reporting that I have no bounties on my head.  However, as the crash happens, the last word fades out, then the VoiceAttack interface disappears.  It's my understanding that if there are any problems with the EDDI script, it will not render the output speech, so I am assuming that it's only fading out because VoiceAttack has stopped.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Voice Attack crashing
« Reply #7 on: April 29, 2021, 11:43:13 PM »
Have you tried reinstalling VoiceAttack, just in case?

You could additionally try a system file scan, just in case


Did the EDDI developers mention whether they're seen this exception before? This is the first time it has been reported, as far as I'm aware.

Especially with the way it only occurs sporadically, there isn't really a way to debug this without more information, unfortunately

Darkcyde

  • Newbie
  • *
  • Posts: 6
Re: Voice Attack crashing
« Reply #8 on: April 30, 2021, 08:59:49 AM »
I shall try reinstalling VoiceAttack.  I'll remove it and delete anything left over, reboot then reinstall, just to make sure.

I'll also give the SFC a go too.

The EDDI devs didn't say if they had or hadn't seen it before.  Although, I think this is just as new to them as it is to yourself.  You can see my posts and their answers here: https://forums.frontier.co.uk/threads/eddi-3-3-bring-your-cockpit-to-life.387955/post-9118890

I figured as much, regarding trying to debug this.  While I don't know much about VoiceAttack, everything seems simple enough in the code I've written, and I can't see any reason for the crash happening at all.  I will gladly provide any info you need, should you wish to pursue this further.

I used to have another problem with VA for some time, where after a random amount of time, it would stop listening to my voice commands.  I could click to manually execute everything still, and all commands would work as normal, just the listening would stop.  Clicking on the headphones icon wouldn't work properly either, with it getting stuck on or off.  Since moving over to a 64bit version, this problem has gone away, but it does make me wonder if there's not something slightly wrong with my setup that could cause these things to be random.

Anyway,  I'll let you know how I get on with the reinstall and SFC.  Thanks for your help so far. :)

Darkcyde

  • Newbie
  • *
  • Posts: 6
Re: Voice Attack crashing
« Reply #9 on: May 01, 2021, 02:54:42 PM »
I just thought I'd let you know how I've been doing regarding this.

So, I uninstalled EDDI and VoiceAttack, and deleted any left over files.  I then rebooted my PC and ran SFC /scannow.  This said it found and fixed a couple of problems, but because I forgot to ask for a log, I don't know what those were.  I don't think it could have been much as it didn't take very long to complete at all, maybe 2-3 minutes or so.

After that, I reinstalled VoiceAttack and EDDI.  I recreated my VA command, and copied over the EDDI script for 'Ship targeted'.  Then I tried to make it crash again.  I tried various combinations of rebooting, restarting the game and VoiceAttack, and targetting my ship multiple times.  It didn't crash once.

I've now copied back my VA profile and EDDI personality, and been trying to make it all crash again for the last two days.  So far, it hasn't crashed once, but considering this problem was intermittent in the first place, I may not see it crash again for a few more days, although I would have expected it to have done so at least once or twice by now.

So I'm hoping the reinstall of everything has fixed it, but only time will tell.  As it stands, I'm happy to say it's fixed, so thank you very much for the advice, and for taking the time to help with this.  :)