{"action":"created","issue":{"url":"https://api.github.com/repos/KSP-KOS/KOS/issues/1980","repository_url":"https://api.github.com/repos/KSP-KOS/KOS","labels_url":"https://api.github.com/repos/KSP-KOS/KOS/issues/1980/labels{/name}","comments_url":"https://api.github.com/repos/KSP-KOS/KOS/issues/1980/comments","events_url":"https://api.github.com/repos/KSP-KOS/KOS/issues/1980/events","html_url":"https://github.com/KSP-KOS/KOS/issues/1980","id":220131313,"number":1980,"title":"Very long freeze when vessels dock by script.","user":{"login":"Dunbaratu","id":5216848,"avatar_url":"https://avatars3.githubusercontent.com/u/5216848?v=3","gravatar_id":"","url":"https://api.github.com/users/Dunbaratu","html_url":"https://github.com/Dunbaratu","followers_url":"https://api.github.com/users/Dunbaratu/followers","following_url":"https://api.github.com/users/Dunbaratu/following{/other_user}","gists_url":"https://api.github.com/users/Dunbaratu/gists{/gist_id}","starred_url":"https://api.github.com/users/Dunbaratu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dunbaratu/subscriptions","organizations_url":"https://api.github.com/users/Dunbaratu/orgs","repos_url":"https://api.github.com/users/Dunbaratu/repos","events_url":"https://api.github.com/users/Dunbaratu/events{/privacy}","received_events_url":"https://api.github.com/users/Dunbaratu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-04-07T07:19:50Z","updated_at":"2017-04-09T17:55:17Z","closed_at":null,"body":"## To re-create the problem\r\n\r\n1. You don't need any other mods.  You can start from an installation of KSP 1.2.2 that only has the kOS current ``develop`` branch installed on it.\r\n2. At the bottom of this issue there's an attached saved game ZIP file.  Extract it into your saved games folder, and then launch KSP and you should have a saved game called \"VesselMergeBug - BeforeDock\".\r\n3. Open that saved game, go to the tracking center, and fly the ship called ``client_craft``.\r\n4. Turn off the SAS on ``client_craft`` (I accidentally left it on in the saved game and it will mess with the steering if you leave it on).\r\n5. Open both ships' terminals.  (``client craft`` is near another vessel called ``server_craft`` that is a bit south of it.  They should be within about 90 meters of each other so you should be able to have both windows open at the same time.)\r\n6. (Note, given where the saved game is starting from, you may have to time warp a very small amount to get signal to reach the vessels before you do the next step - I saved the game at a point just before they're about to pass over a ground station, to give the largest possible time window to talk to them and fiddle about.).\r\n7. On both the ``server_craft`` and the ``client_craft`` terminals, hit **control-C** to stop the ``just_obey_nodes`` script (which is the boot file so it will auto-run when you load the scene) and dump you back to the interpreter for both.\r\n8. On the ``server_craft`` terminal, do ``run station_dock_server.``\r\n9. On the ``client_craft`` terminal, do ``run station_dock_client.``\r\n10. Wait for them to finish docking to each other, and pay attention to what happens at the moment of vessel merging.\r\n\r\n## What happens\r\n\r\nWhen the vessels merge together, the game freezes for about 6 or 7 seconds.  It's longer than the normal amount of time the stock game takes to merge vessels together.  (I've seen it take a VERY long time - 30 to 60 seconds or so, in some more complex instances before I narrowed down the example to a smaller scenario in a newly started game.)\r\n\r\nAlso, after the merge, in addition to the (entirely expected) error message complaining that both kOS units are now trying to control the same vessel, you will also see the (unexpected) spamming of a null reference exception over and over and over, apparently once per FixedUpdate.\r\n\r\nThat exception looks like this:\r\n```\r\nNullReferenceException: Object reference not set to an instance of an object\r\n  at kOS.Safe.Execution.CPU.SkipCurrentInstructionId () [0x00000] in <filename unknown>:0 \r\n  at kOS.Safe.Execution.CPU.KOSFixedUpdate (Double deltaTime) [0x00000] in <filename unknown>:0 \r\n  at kOS.Safe.UpdateHandler.UpdateFixedObservers (Double deltaTime) [0x00000] in <filename unknown>:0 \r\n  at kOS.Module.kOSProcessor.UpdateFixedObservers () [0x00000] in <filename unknown>:0 \r\n  at kOS.Module.kOSProcessor.FixedUpdate () [0x00000] in <filename unknown>:0 \r\n ```\r\n(This exception is also dumping the program instructions to the log each time, in the same way that errors that are the script's fault normally do.)\r\n\r\n## It only happens if the script is in control of the docking.\r\n\r\nIf you don't use the scripts, and instead fly the vessels under manual control to do the docking, the bug does not happen.  The two vessels merge together nicely without the long freeze.\r\n\r\n## It is something that changed recently\r\n\r\nIf you perform the exact same steps above, but this time use the publicly released kOS 1.0.3 ZIP file from CKAN instead of using the current `develop` branch, the bug does not occur.  The ships merge together quickly (under either manual or script control), and you only get the 1 (expected) error message from the fact that two kOS cores are both trying to control the lock steering at the same time.\r\n\r\n(Saved game ZIP is here:)\r\n[JustBeforeDockingBug.zip](https://github.com/KSP-KOS/KOS/files/904789/JustBeforeDockingBug.zip)\r\n"},"comment":{"url":"https://api.github.com/repos/KSP-KOS/KOS/issues/comments/292801178","html_url":"https://github.com/KSP-KOS/KOS/issues/1980#issuecomment-292801178","issue_url":"https://api.github.com/repos/KSP-KOS/KOS/issues/1980","id":292801178,"user":{"login":"Dunbaratu","id":5216848,"avatar_url":"https://avatars3.githubusercontent.com/u/5216848?v=3","gravatar_id":"","url":"https://api.github.com/users/Dunbaratu","html_url":"https://github.com/Dunbaratu","followers_url":"https://api.github.com/users/Dunbaratu/followers","following_url":"https://api.github.com/users/Dunbaratu/following{/other_user}","gists_url":"https://api.github.com/users/Dunbaratu/gists{/gist_id}","starred_url":"https://api.github.com/users/Dunbaratu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dunbaratu/subscriptions","organizations_url":"https://api.github.com/users/Dunbaratu/orgs","repos_url":"https://api.github.com/users/Dunbaratu/repos","events_url":"https://api.github.com/users/Dunbaratu/events{/privacy}","received_events_url":"https://api.github.com/users/Dunbaratu/received_events","type":"User","site_admin":false},"created_at":"2017-04-09T17:55:17Z","updated_at":"2017-04-09T17:55:17Z","body":"When I fixed the problem with the freezing, I just discovered that the problem with the log spam just after docking is in fact a separate independent bug, so I'm going to split that off into a second issue so it can be tracked and solved independantly of this one.\r\n"}}
{"actor":{"display_login":"Dunbaratu"}}