s-victor / TinyPedal

Free and Open Source telemetry overlay application for racing simulation
GNU General Public License v3.0
75 stars 8 forks source link

The widgets disappear after a few seconds when the app has focus #21

Closed berarma closed 1 year ago

berarma commented 1 year ago

This happens on Linux, I couldn't test on Windows.

I'm on the track, and I focus the app to relocate the widgets. In the midst of relocating the widgets they disappear. They reappear when rFactor 2 regains focus.

Doesn't it happen on Windows?

berarma commented 1 year ago

I've found the code resets the mmaps when it detects there are no more updates in the data. I guess that's a workaround for some issue where TinyPedal stopped getting updates. This is the reason the widgets disappear.

Shouldn't the widgets stay even if the data isn't updating?

I'd like to know how does it work on Windows to try to get the same behavior on Linux.

s-victor commented 1 year ago

The current hide status check is based on vehicle ignition state. If vehicle engine stall, then it will trigger hide(if auto-hide is On). Make sure that engine ignition is on, and see if the problem goes away.

berarma commented 1 year ago

When the mmap module restarts the ignition turns to off, I'm not sure why.

s-victor commented 1 year ago

At which condition have you encountered mmap restarts?

Normally mmap should only restart if it detects the API data stream version stopped updating (mVersionUpdateBegin & mVersionUpdateEnd values, which you have fixed ctypes types earlier on those two values).

The mmap restart usually happens during track loading or session changing, or game crash or game paused, or disconnection from server, where both mVersionUpdateBegin & mVersionUpdateEnd values could stop updating in those condition, which triggers restarts.

berarma commented 1 year ago

rFactor 2 pauses automatically when I change focus to TinyPedal.

s-victor commented 1 year ago

I see, it is a game thing, try this: Close game first, then in rFactor 2\UserData\player folder, open player.JSON, find this line: "Pause If Focus Lost":true, Set it to false. Reboot game, and all should be good.

berarma commented 1 year ago

I'd like to keep the game pausing but now I know why does it happen. Thanks.

s-victor commented 1 year ago

no problem.

Currently the main reason for mmap restart is to solve the problem where game crashes or player disconnected from server while player is driving, which under both situations, API data stream would stop updating, and last player status will always be "ON track", which the app will remain visible to player even though player is in the main menu or crashed to desktop.

While for game crash, restarting TP could resolve the not hiding problem since last API data stream is no longer in memory. However for disconnection, restarting TP will not make the app hide again, since last API data stream is still in memory with "ON track" status, and the only way for player to solve it is to either load a track (so that a newer data stream is updated), or restart game, which is not user friendly.

Lemme know if there is other issue, thanks!

berarma commented 1 year ago

I get it. There's currently no way to tell apart when the game has crashed or disconnected from when it's just paused.

Still, the way it behaves when pausing on focus lost is weird.

Could we make the widgets visible when TinyPedal has the focus? Would it make sense to you?

s-victor commented 1 year ago

Yes, good idea. Auto disable auto-hide when player is on track and main window is visible. I'll take a look.

s-victor commented 1 year ago

Ok, I took a look and seems it will complicate things, so I guess no changes made atm. User can always manually disable auto-hide. There will be a major changes to GUI library in next v2.0 update, which tkinter will be replaced, so will see when get there. thanks for the help