Page MenuHomeWildfire Games

Do not thread the game in Atlas [WIP]
Needs ReviewPublic

Authored by wraitii on Tue, May 19, 9:53 PM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Trac Tickets
#5470
Summary

This was much easier than I thought :P.


This is a fix for a crash on Mac OS Catalina. D2019 reported issues with video setup in a separate thread, but it turns out it actually crashes, and D2019 is not enough to fix it (in fact I think it's partly the issue, by virtue that further graphics call must be on the initialiser thread).

The simplest solution I find to fixing these issues, which actually date back to #500, is to not put Atlas and the game in separate threads.
The reason for this architecture seems to be found here (staff forum thread). Basically, it was reasoned that it would help the editor not lag even if the game itself lagged.

The implementation of messages and such in Atlas makes it rather easy to not actually do threading. With the need for threading removed, a (much?) simpler implementation is likely possible, but this is a working first step (cleanup pending).

In my quick tests, I haven't noticed anything broken or obviously not working. I haven't yet bothered to reimplement "renderer incremental loop".


Pros of unthreading:

  • Code will be slightly easier to maintain and we might actually end up removing some magic form Atlas.
  • Less concern about the editor burning 100% of CPU if we reduce the frame rate.
  • Less concern about threading in other parts of the code because Atlas is no longer particularly special.
  • Any threading-UI error that might pop up in the future is preventively squashed.

Cons of unthreading:

  • Does reduce performance of Atlas tools slightly (though I don't think we had many tools that didn't run in the engine thread anyways).
  • Might be a slightly worse experience if the game frame really lags.
  • To an extent, it puts the whole DLL architecture in question too.

Makes D2019 and D1922 irrelevant (and ergo fixes #5470)


User wik has a different fix at https://wildfiregames.com/forum/index.php?/topic/28183-trunk23664-cant-open-atlas-editor-on-osx-catalina-10154/&tab=comments#comment-396649, which involves patching wxWidgets.

Test Plan

This is WIP as it stands, but it should work.

Event Timeline

wraitii created this revision.Tue, May 19, 9:53 PM
Owners added a subscriber: Restricted Owners Package.Tue, May 19, 9:53 PM
wraitii updated this revision to Diff 11931.Tue, May 19, 10:01 PM

Slightly less crap version.

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/tools/atlas/GameInterface/Messages.h
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/tools/atlas/GameInterface/Messages.h
|  25| #include·<vector>
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'namespaceAtlasMessage{' is invalid C code. Use --std or --language to configure the language.

source/tools/atlas/GameInterface/Messages.h
| 211| »   »   ,
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Unmatched '}'. Configuration: 'MESSAGESSETUP_NOTFIRST'.

source/tools/atlas/GameInterface/MessagePasserImpl.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/tools/atlas/GameInterface/MessagePasserImpl.cpp
| 211| The line belonging to the following result cannot be printed because it refers to a line that doesn't seem to exist in the given file.
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Unmatched '}'. Configuration: 'MESSAGESSETUP_NOTFIRST'.

source/tools/atlas/GameInterface/GameLoop.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/tools/atlas/GameInterface/GameLoop.cpp
| 211| »   »   //////////////////////////////////////////////////////////////////////////
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Unmatched '}'. Configuration: 'MESSAGESSETUP_NOTFIRST'.

source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp
| 211| »   g_Input.ProcessInput(g_AtlasGameLoop);
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Unmatched '}'. Configuration: 'MESSAGESSETUP_NOTFIRST'.
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2166/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Linter detected issues:
Executing section Source...

source/tools/atlas/GameInterface/MessagePasser.h
|   1| /*·Copyright·(C)·2009·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2009"

source/tools/atlas/GameInterface/MessagePasser.h
|  25| 
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'namespaceAtlasMessage{' is invalid C code. Use --std or --language to configure the language.

source/tools/atlas/GameInterface/MessagePasserImpl.h
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/tools/atlas/GameInterface/MessagePasserImpl.h
|  25| #include·<queue>
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'namespaceAtlasMessage{' is invalid C code. Use --std or --language to configure the language.

source/tools/atlas/GameInterface/Messages.h
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/tools/atlas/GameInterface/Messages.h
|  25| #include·<vector>
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Code 'namespaceAtlasMessage{' is invalid C code. Use --std or --language to configure the language.

source/tools/atlas/GameInterface/Messages.h
| 211| »   »   ,
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Unmatched '}'. Configuration: 'MESSAGESSETUP_NOTFIRST'.

source/tools/atlas/GameInterface/MessagePasserImpl.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/tools/atlas/GameInterface/MessagePasserImpl.cpp
| 211| The line belonging to the following result cannot be printed because it refers to a line that doesn't seem to exist in the given file.
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Unmatched '}'. Configuration: 'MESSAGESSETUP_NOTFIRST'.

source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/tools/atlas/GameInterface/GameLoop.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/tools/atlas/GameInterface/GameLoop.cpp
| 211| The line belonging to the following result cannot be printed because it refers to a line that doesn't seem to exist in the given file.
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Unmatched '}'. Configuration: 'MESSAGESSETUP_NOTFIRST'.

source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp
|   1| /*·Copyright·(C)·2019·Wildfire·Games.
|    | [NORMAL] LicenseYearBear:
|    | License should have "2020" year instead of "2019"

source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp
| 211| 
|    | [MAJOR] CPPCheckBear (syntaxError):
|    | Unmatched '}'. Configuration: 'MESSAGESSETUP_NOTFIRST'.
Executing section JS...
Executing section cli...

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/2167/display/redirect

wraitii added a subscriber: vladislavbelov.EditedWed, May 20, 8:44 AM

Edit: the below fixed by wik at https://wildfiregames.com/forum/index.php?/topic/28183-trunk23664-cant-open-atlas-editor-on-osx-catalina-10154/&tab=comments#comment-396649
somewhat. It's fixable anyways.


This does fix the UI thread issues on Catalina, however I get an SDL assertion failure:

Assertion failure at SDL_GetWindowWMInfo_REAL (/Users/Shared/github_repos/0ad/libraries/osx/sdl2/SDL2-2.0.12/src/video/SDL_video.c:3760), triggered 1 time:
  'window && window->magic == &_this->window_magic'

and further the screen is indeed only displayed on ¼ of the screen. @vladislavbelov reports this happens on other platforms too, so that may or may not be a separate issue.

(Ignoring the above assertion failure "works" as in the game doesn't crash)

wraitii edited the summary of this revision. (Show Details)Wed, May 20, 8:46 AM
wraitii edited the summary of this revision. (Show Details)Wed, May 20, 8:54 AM