From c78dc837f2538d1f57fa42cacf74394643aa1cff Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 3 Jun 2023 21:53:19 -0700 Subject: [PATCH] better logging on BA_PRECONDITION failures --- .efrocachemap | 40 ++++----- CHANGELOG.md | 2 +- src/assets/ba_data/python/babase/_app.py | 83 ++++++++++--------- src/assets/ba_data/python/baenv.py | 2 +- src/ballistica/base/app/app_mode_empty.cc | 3 +- src/ballistica/base/base.cc | 5 +- .../scene_v1/support/scene_v1_app_mode.cc | 3 +- src/ballistica/shared/ballistica.cc | 2 +- 8 files changed, 71 insertions(+), 69 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 6db739f2..430f7a4b 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4072,26 +4072,26 @@ "build/assets/workspace/ninjafightplug.py": "https://files.ballistica.net/cache/ba1/c5/09/4f10b8a21ba87aa5509cff7a164b", "build/assets/workspace/onslaughtplug.py": "https://files.ballistica.net/cache/ba1/ff/0a/a354984f9c074dab0676ac7e4877", "build/assets/workspace/runaroundplug.py": "https://files.ballistica.net/cache/ba1/2a/1c/9ee5db6d1bceca7fa6638fb8abde", - "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/b0/77/0fb608a5a11844433c94237b80fd", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/6b/37/9122b03565ee2d08d9fc6d30a221", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a4/11/0f7c0fe6af5d5e46795f33b53f8e", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/59/f4/7e5d155abb264a76b633d6f4225f", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/dc/0a/131caf082f3877e5878ae349746d", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/fb/46/34eada1e570cce2107cb55a033e8", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/1d/3e/be779b3740cda2a7d98418d4007a", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/18/b7/4389f6000decbcde1044180b134a", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/15/fa/f657184f4b7049dec6b9536a3cac", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/01/b4/31635bc46cbda94cc73fc019d28c", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/07/65/ad3d172ccc9fa64c740654d0520c", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d7/17/7f186bd856ea7bd18b2fc8d64639", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/f5/98/1a151f4155937cec4ac5a68157de", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/19/ca/ae8153fb5fd0ea1045d386c31134", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/fd/5b/aea65f345280262561c6ea046c5f", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/e2/8a/0ae529b92bcf4afe5d1c9c797e96", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/7c/63/04f6b60329b003e8f6c7de88be64", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/27/4f/0ccc0d399b4e5d9152891cbe9899", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/b6/50/deb28410d237467f15756ddc3b4a", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/c8/49/976a5a3945513be88a7333f45ed0", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/91/55/d613e7b8f4c46014c348d0ed9c51", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/2b/a9/e56c7defaf9131a15723393670f2", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/2a/93/b541f7371ae7aa9c2b6df54e0a3c", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/f9/54/6e50c747a802a688700e3570e1da", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/01/06/dbd917364037462ef11f47d053fb", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/2a/57/9df425e36c1462d3987df2416df9", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/8b/70/a50ce6901458a7343b34ea3e9fde", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/e6/87/d655f427d8191fde17c1c642b6d5", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/7d/97/1987d3c17870049d0b96864fd8b8", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/55/8e/6637c52fd4cb296d2fea01cb5c56", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/dc/28/d47732690963cc3cc2d0424ea944", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/85/3c/0bac934332bcef62ebe133280150", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/cd/83/361d69461f3cc129666897dd348a", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/62/9b/66fad8addd5c3ac0a94292651e37", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/0c/f3/ea8ba8a2e73fd677e3f654e67184", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d3/3e/e2515e5356429fa3984fa8b464e0", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/6b/cc/7e1168c16d21e839639697004da3", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/45/a7/e3f4df84afe580d16f9f2d2ae6ae", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/db/f8/a2a99ce1869390e5c1c3bc7f7fa0", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/71/ea/5f168531d49dd779e87db5374b57", "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/d4/6a/dd303a200b98a56ba3b100277057", "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/fc/2c/2996c558fb408a548fdd37398c9a", "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/ed/28/b7a72be7ae1bd2b58dda4b6902a0", diff --git a/CHANGELOG.md b/CHANGELOG.md index fbd05d95..370036d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.20 (build 21042, api 8, 2023-06-02) +### 1.7.20 (build 21044, api 8, 2023-06-03) - This seems like a good time for a `refactoring` release in anticipation of changes coming in 1.8. Basically this means that a lot of things will be diff --git a/src/assets/ba_data/python/babase/_app.py b/src/assets/ba_data/python/babase/_app.py index 44231679..e0881fee 100644 --- a/src/assets/ba_data/python/babase/_app.py +++ b/src/assets/ba_data/python/babase/_app.py @@ -455,8 +455,19 @@ class App: """ _babase.run_app() + def on_app_bootstrapping_complete(self) -> None: + """Called by the C++ layer once its ready to rock.""" + assert _babase.in_logic_thread() + assert not self._app_bootstrapping_complete + self._app_bootstrapping_complete = True + self._update_state() + + assert not self._meta_scan_completed + self._meta_scan_completed = True + self._update_state() + def on_app_launching(self) -> None: - """Called when the app is first entering the launching state.""" + """Called when the app is entering the launching state.""" # pylint: disable=cyclic-import from babase import _asyncio from babase import _appconfig @@ -497,37 +508,16 @@ class App: self._update_state() def on_app_loading(self) -> None: - """Called when initially entering the loading state.""" + """Called when the app is entering the loading state.""" assert _babase.in_logic_thread() - class DefaultAppModeSelector(AppModeSelector): - """Decides which app modes to use to handle intents. - - The behavior here is generated by the project updater based on - the set of feature-sets in the project. Spinoff projects can - also inject their own behavior by replacing the - __ADD_CUSTOM_SPINOFF_LOGIC_HERE__ comment with their own code. - - Note that it is also possible to modify mode selection behavior - by completely replacing the app.mode_selector with an instance - of a custom AppModeSelector subclass. This is probably the best - route for plugins wanting to do such things. - """ - - def app_mode_for_intent(self, intent: AppIntent) -> type[AppMode]: - # __ADD_CUSTOM_SPINOFF_LOGIC_HERE__ - - # __DEFAULT_APP_MODE_SELECTION_BEGIN__ - # This section generated by batools.appmodule; do not edit. - - import bascenev1 - - return bascenev1.SceneV1AppMode - - # __DEFAULT_APP_MODE_SELECTION_END__ + def on_meta_scan_complete(self) -> None: + """Called when meta-scan is done doing its thing.""" + assert _babase.in_logic_thread() + self.plugins.on_meta_scan_complete() def on_app_running(self) -> None: - """Called when initially entering the running state.""" + """Called when the app is entering the running state.""" assert _babase.in_logic_thread() # Let the native layer know. @@ -549,21 +539,32 @@ class App: # plugin hasn't already told it to do something. self.set_intent(AppIntentDefault()) - def on_app_bootstrapping_complete(self) -> None: - """Called by the C++ layer once its ready to rock.""" - assert _babase.in_logic_thread() - assert not self._app_bootstrapping_complete - self._app_bootstrapping_complete = True - self._update_state() + class DefaultAppModeSelector(AppModeSelector): + """Decides which app modes to use to handle intents. - def on_meta_scan_complete(self) -> None: - """Called by meta-scan when it is done doing its thing.""" - assert _babase.in_logic_thread() - self.plugins.on_meta_scan_complete() + The behavior here is generated by the project updater based on + the set of feature-sets in the project. Spinoff projects can + also inject their own behavior by replacing the + __ADD_CUSTOM_SPINOFF_LOGIC_HERE__ comment with their own code + through spinoff filtering. - assert not self._meta_scan_completed - self._meta_scan_completed = True - self._update_state() + Note that it is also possible to modify mode selection behavior + by writing a custom AppModeSelector class and replacing + app.mode_selector with an instance of it. This is a good way to + go if you are wanting to modify app behavior with a plugin. + """ + + def app_mode_for_intent(self, intent: AppIntent) -> type[AppMode]: + # __ADD_CUSTOM_SPINOFF_LOGIC_HERE__ + + # __DEFAULT_APP_MODE_SELECTION_BEGIN__ + # This section generated by batools.appmodule; do not edit. + + import bascenev1 + + return bascenev1.SceneV1AppMode + + # __DEFAULT_APP_MODE_SELECTION_END__ def _update_state(self) -> None: # pylint: disable=too-many-branches diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 6c2ee7fd..833d8544 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -30,7 +30,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21042 +TARGET_BALLISTICA_BUILD = 21044 TARGET_BALLISTICA_VERSION = '1.7.20' _g_env_config: EnvConfig | None = None diff --git a/src/ballistica/base/app/app_mode_empty.cc b/src/ballistica/base/app/app_mode_empty.cc index abc45e20..88e91c32 100644 --- a/src/ballistica/base/app/app_mode_empty.cc +++ b/src/ballistica/base/app/app_mode_empty.cc @@ -9,9 +9,8 @@ static AppModeEmpty* g_app_mode_empty{}; AppModeEmpty::AppModeEmpty() = default; auto AppModeEmpty::GetSingleton() -> AppModeEmpty* { - // TODO(ericf): Turn this back on once we're creating in logic thread. + assert(g_base == nullptr || g_base->InLogicThread()); - // assert(g_base->InLogicThread()); // Can relax this if need be. if (g_app_mode_empty == nullptr) { g_app_mode_empty = new AppModeEmpty(); } diff --git a/src/ballistica/base/base.cc b/src/ballistica/base/base.cc index 5aa7ecf1..a52c21c5 100644 --- a/src/ballistica/base/base.cc +++ b/src/ballistica/base/base.cc @@ -206,6 +206,7 @@ void BaseFeatureSet::LogVersionInfo() { void BaseFeatureSet::set_app_mode(AppMode* mode) { assert(InLogicThread()); + if (mode == app_mode_) { Log(LogLevel::kWarning, "set_app_mode called with already-current app-mode; unexpected."); @@ -213,7 +214,7 @@ void BaseFeatureSet::set_app_mode(AppMode* mode) { try { // Tear down previous mode (if any). if (app_mode_) { - // Nothing here yet. + app_mode_->OnDeactivate(); } // Set and build up new one. @@ -221,6 +222,8 @@ void BaseFeatureSet::set_app_mode(AppMode* mode) { // App modes each provide their own input-device delegate types. input->RebuildInputDeviceDelegates(); + + app_mode_->OnActivate(); } catch (const Exception& exc) { // Anything going wrong while switching app-modes leaves us in an // undefined state; don't try to continue. diff --git a/src/ballistica/scene_v1/support/scene_v1_app_mode.cc b/src/ballistica/scene_v1/support/scene_v1_app_mode.cc index ba450bc4..168d9154 100644 --- a/src/ballistica/scene_v1/support/scene_v1_app_mode.cc +++ b/src/ballistica/scene_v1/support/scene_v1_app_mode.cc @@ -359,9 +359,8 @@ auto SceneV1AppMode::GetActiveOrFatal() -> SceneV1AppMode* { } auto SceneV1AppMode::GetSingleton() -> SceneV1AppMode* { - // TODO(ericf): Turn this back on once we're creating in logic thread. + assert(g_base->InLogicThread()); - // assert(g_base->InLogicThread()); // Can relax this if need be. if (g_scene_v1_app_mode == nullptr) { g_scene_v1_app_mode = new SceneV1AppMode(); } diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index f4a5813d..cd5613af 100644 --- a/src/ballistica/shared/ballistica.cc +++ b/src/ballistica/shared/ballistica.cc @@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int { namespace ballistica { // These are set automatically via script; don't modify them here. -const int kEngineBuildNumber = 21042; +const int kEngineBuildNumber = 21044; const char* kEngineVersion = "1.7.20"; auto MonolithicMain(const core::CoreConfig& core_config) -> int {