20,741
edits
| Line 170: | Line 170: | ||
At the moment, the fgais background thread will sleep until 60 seconds have passed, only then, will it start downloading/parsing/computing new data. However, by that time, the fgms main thread is already "starving", because it has no more data to send to the fgfs client - in other words, it has to wait until the worker thread has completed. We should be preparing a new set of data earlier than that. For now, a usable workaround would be to compute even more data and use a FIFO | At the moment, the fgais background thread will sleep until 60 seconds have passed, only then, will it start downloading/parsing/computing new data. However, by that time, the fgms main thread is already "starving", because it has no more data to send to the fgfs client - in other words, it has to wait until the worker thread has completed. We should be preparing a new set of data earlier than that. For now, a usable workaround would be to compute even more data and use a FIFO | ||
it's because we have sent all our positions in stock (1...59) then the download() lock all. The problem is that the new download() come after 60 seconds but he take 6~10 seconds, the result is : | |||
* 0s : first download (took 8s) | |||
* 8s : parse and recompute (took 0.5s) | |||
* 8,5s : start to send our first position, since we have 60 position we can go at 68,5 seconds | |||
* 68s : new download (took 8s seonds) | |||
* 76s :parse and recompute (took 0.5s) | |||
* 76.5 : start to send our positions | |||
As you can see between 68.5s and 76.5s we have sent no position to our client, our client has passed 8 seconds without receiving position. Imagine that we have some trouble with the connection, the download can take 10s and with 10 seconds of download : the client doesn't receive data during 12 seconds. Since 10 seconds is the limit of live : our AI traffic is gone at the client side. | |||
To solve it we need to force download every (60s - prevDownloadTime) or use a scheduler. But it's not really a big problem, it's easy to solve. We can also simply reduce the time between each download but keep the generation of 60 positions. | |||
* we should *never* iterate through the whole AI list in the main thread *never* | * we should *never* iterate through the whole AI list in the main thread *never* | ||