From 9bc672605dc8cdaa5969aba16de288d41674843e Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 8 Jun 2023 11:43:45 -0700 Subject: [PATCH 1/7] clearer logging on fatal errors when stack traces are not available --- .efrocachemap | 56 +++++++++---------- CHANGELOG.md | 2 +- src/assets/ba_data/python/baenv.py | 2 +- src/ballistica/base/base.cc | 55 +++++++++--------- .../base/python/methods/python_methods_app.cc | 6 +- src/ballistica/core/core.cc | 8 +++ src/ballistica/core/python/core_python.cc | 20 ++----- src/ballistica/shared/ballistica.cc | 2 +- .../shared/foundation/fatal_error.cc | 4 +- 9 files changed, 79 insertions(+), 76 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index ab705935..08a98c82 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/02/08/b2319162d3e45bdbf9b6e60157c8", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/e1/a7/7bd6d0e731eb831b298a4400b835", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d4/b1/e6023d13f8d5e90fe9541a290e4b", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/3a/52/3e0cd585d0d6739b01fe8ec9032e", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/50/c8/52c1f1c8467ea32056df8928e046", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/a8/2e/3a4b6faa127cf64ab8a7760433e7", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d1/57/9ae52124b55a6b1f3f5f4cba7216", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/64/5b/fc659b6628076b67f491ca62b174", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/3f/4d/9711985938fb8bd5041dc55de46e", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/19/3d/c3a7f04293dae053b57fe06ffe3e", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/69/56/cc294914a71932cb75beb2bb3094", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/9e/3c/7804a6c319e322f77135f24999e8", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/a7/4e/a64a4b500335fcdb8ae460a60416", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/d4/b6/b62a890f316e8a886f49bd576c33", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/85/2d/328ea96e4729a7f378803c05c60e", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c6/3e/384a51739fb898ce03e88fd165e9", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/5d/0f/ae0078422cbfa2030501db9bf0b5", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/97/91/9a9b875d865949c9d6e28b327b86", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/90/2c/1520b8c574430c4dd8168aa46a9f", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/c1/f0/e3ff659748399873acb4ede80ffd", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/1b/b8/532a6971b2fcde399db71380f199", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/e1/c6/129b00c453204caf4b527a1e7bf5", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ec/2c/9b26c894d69e4f78b29d3e7c14ca", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/26/f9/d6f77a2ed0a847b3cc3cbab51223", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/31/42/26c9e0ead4d1b17960834c0e9a17", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/7b/25/e55d4e007315295d9fbbc19ff3f1", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/91/c3/78db3cff1c37f2028f4cf1dbb435", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/76/34/c5e097bfddd0379b92d9aa1ef42e", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/11/c7/b8c4ce04f15b6ee2a8fe34ed9a8c", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/0c/15/6da0ded38e64fed5778b15a9dc58", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/1d/6d/e7e3ee414c73f2857531de2a362a", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/1d/76/b762b765eaf6c85ca7346cda68ed", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/1c/2b/da531e1c3f5a0778c97175a3ac84", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/da/c7/c2829f0e2aaf47ff706d6cfadb6a", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ad/d0/51afd6f99890fb7a3dbb05ca9d14", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b9/29/d7e921e6239e27ecc39d2dfe9910", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/49/c8/cf436fc6e64192bfc5b23393eeab", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/34/b0/8592d685b1a2c85308ede3494746", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/41/d2/6923abda66b4b7f8c73e8a9ef78b", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/04/30/75863a1df70641893045cd4bf8af", "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/58/55/b6ae6dd4f3615fa87bb170a43233", "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/b9/f8/37285d0ced7794a82534d13c33ac", "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/c7/cc/0c5f0afbfa0ddabaea8d5838562a", @@ -4108,14 +4108,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/96/2e/1b0ba43fe24fe9cc223a434db647", "build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/f3/83/581b7df96f6516032a0747b83e15", "build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/6a/6d/7aaf7617929eeff41bc5a574e6c8", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/c3/00/abea5335d9f30806405451985391", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/bf/f6/a0f57ca4714cdada3469795efa70", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/97/ed/00e71906a026a8b16ed733250177", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/78/5c/9c421525f6a3ed8890d67c0067c0", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/74/33/b42b6e241fa782f6a82292da5fc7", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/4d/f3/0a55b91570b2d9eb40d75317ae3a", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/50/b4/3485d00c1b200dc753a9bef302c3", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/cb/27/82502b5ccea9a47d368e6f8c8c50", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/20/f0/4e9e3644c559e00816a8621a8987", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/7c/39/5390a4370b1c3a931a84abf6f477", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/f8/ec/e98d729c3d66249a1e11aa26af2d", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/62/9c/2c38890b97307365059b162abe51", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/90/81/4d46be8eb3992b016a7c82f5766a", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/18/09/af24159486d0253f900e262d9fd9", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/a8/f5/68bb806fdee3a4694352d1e03a60", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/ee/96/8259473f7ed61dfdb8dd8af6f845", "src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/52/c6/c11130af7b10d6c0321add5518fa", "src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/38/c3/1dedd5e74f2508efc5974c8815a1", "src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/75/9f/bcf597b362c9f2480cb348188bdd", diff --git a/CHANGELOG.md b/CHANGELOG.md index 184adee6..6e62928f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.20 (build 21071, api 8, 2023-06-07) +### 1.7.20 (build 21072, api 8, 2023-06-08) - 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/baenv.py b/src/assets/ba_data/python/baenv.py index 0f3320b3..016a6554 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -28,7 +28,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21071 +TARGET_BALLISTICA_BUILD = 21072 TARGET_BALLISTICA_VERSION = '1.7.20' _g_env_config: EnvConfig | None = None diff --git a/src/ballistica/base/base.cc b/src/ballistica/base/base.cc index de4c7f1c..5e2c8c20 100644 --- a/src/ballistica/base/base.cc +++ b/src/ballistica/base/base.cc @@ -134,9 +134,7 @@ void BaseFeatureSet::OnModuleExec(PyObject* module) { void BaseFeatureSet::OnReachedEndOfBaBaseImport() { assert(!base_import_completed_); - g_base->python->ImportPythonAppObjs(); - base_import_completed_ = true; } @@ -176,12 +174,12 @@ void BaseFeatureSet::StartApp() { // Read the app config. g_base->python->ReadConfig(); - // Allow our subsystems to start doing work in their own threads - // and communicating with other subsystems. Note that we may still - // want to run some things serially here and ordering may be important - // (for instance we want to give our main thread a chance to register - // all initial input devices with the logic thread before the logic - // thread applies the current config to them). + // Allow our subsystems to start doing work in their own threads and + // communicating with other subsystems. Note that we may still want to run + // some things serially here and ordering may be important (for instance + // we want to give our main thread a chance to register all initial input + // devices with the logic thread before the logic thread applies the + // current config to them). python->OnMainThreadStartApp(); logic->OnMainThreadStartApp(); @@ -226,6 +224,7 @@ void BaseFeatureSet::set_app_mode(AppMode* mode) { Log(LogLevel::kWarning, "set_app_mode called with already-current app-mode; unexpected."); } + try { // Tear down previous mode (if any). if (app_mode_) { @@ -275,9 +274,9 @@ void BaseFeatureSet::PrimeAppMainThreadEventPump() { auto BaseFeatureSet::HavePlus() -> bool { if (!plus_soft_ && !tried_importing_plus_) { python->SoftImportPlus(); - // Important to set this *after* import attempt, or a second import attempt - // while first is ongoing can insta-fail. Multiple import attempts shouldn't - // hurt anything. + // Important to set this *after* import attempt, or a second import + // attempt while first is ongoing can insta-fail. Multiple import + // attempts shouldn't hurt anything. tried_importing_plus_ = true; } return plus_soft_ != nullptr; @@ -292,9 +291,9 @@ void BaseFeatureSet::set_plus(PlusSoftInterface* plus) { auto BaseFeatureSet::plus() -> PlusSoftInterface* { if (!plus_soft_ && !tried_importing_plus_) { python->SoftImportPlus(); - // Important to set this *after* import attempt, or a second import attempt - // while first is ongoing can insta-fail. Multiple import attempts shouldn't - // hurt anything. + // Important to set this *after* import attempt, or a second import + // attempt while first is ongoing can insta-fail. Multiple import + // attempts shouldn't hurt anything. tried_importing_plus_ = true; } if (!plus_soft_) { @@ -306,9 +305,9 @@ auto BaseFeatureSet::plus() -> PlusSoftInterface* { auto BaseFeatureSet::HaveClassic() -> bool { if (!classic_soft_ && !tried_importing_classic_) { python->SoftImportClassic(); - // Important to set this *after* import attempt, or a second import attempt - // while first is ongoing can insta-fail. Multiple import attempts shouldn't - // hurt anything. + // Important to set this *after* import attempt, or a second import + // attempt while first is ongoing can insta-fail. Multiple import + // attempts shouldn't hurt anything. tried_importing_classic_ = true; } return classic_soft_ != nullptr; @@ -318,9 +317,9 @@ auto BaseFeatureSet::HaveClassic() -> bool { auto BaseFeatureSet::classic() -> ClassicSoftInterface* { if (!classic_soft_ && !tried_importing_classic_) { python->SoftImportClassic(); - // Important to set this *after* import attempt, or a second import attempt - // while first is ongoing can insta-fail. Multiple import attempts shouldn't - // hurt anything. + // Important to set this *after* import attempt, or a second import + // attempt while first is ongoing can insta-fail. Multiple import + // attempts shouldn't hurt anything. tried_importing_classic_ = true; } if (!classic_soft_) { @@ -337,9 +336,9 @@ void BaseFeatureSet::set_classic(ClassicSoftInterface* classic) { auto BaseFeatureSet::HaveUIV1() -> bool { if (!ui_v1_soft_ && !tried_importing_ui_v1_) { python->SoftImportUIV1(); - // Important to set this *after* import attempt, or a second import attempt - // while first is ongoing can insta-fail. Multiple import attempts shouldn't - // hurt anything. + // Important to set this *after* import attempt, or a second import + // attempt while first is ongoing can insta-fail. Multiple import + // attempts shouldn't hurt anything. tried_importing_ui_v1_ = true; } return ui_v1_soft_ != nullptr; @@ -349,9 +348,9 @@ auto BaseFeatureSet::HaveUIV1() -> bool { auto BaseFeatureSet::ui_v1() -> UIV1SoftInterface* { if (!ui_v1_soft_ && !tried_importing_ui_v1_) { python->SoftImportUIV1(); - // Important to set this *after* import attempt, or a second import attempt - // while first is ongoing can insta-fail. Multiple import attempts shouldn't - // hurt anything. + // Important to set this *after* import attempt, or a second import + // attempt while first is ongoing can insta-fail. Multiple import + // attempts shouldn't hurt anything. tried_importing_ui_v1_ = true; } if (!ui_v1_soft_) { @@ -380,8 +379,8 @@ auto BaseFeatureSet::GetAppInstanceUUID() -> const std::string& { } } if (!have_app_instance_uuid) { - // As an emergency fallback simply use a single random number. - // We should probably simply disallow this before Python is up. + // As an emergency fallback simply use a single random number. We + // should probably simply disallow this before Python is up. Log(LogLevel::kWarning, "GetSessionUUID() using rand fallback."); srand(static_cast( core::CorePlatform::GetCurrentMillisecs())); // NOLINT diff --git a/src/ballistica/base/python/methods/python_methods_app.cc b/src/ballistica/base/python/methods/python_methods_app.cc index f38af184..2e5d562d 100644 --- a/src/ballistica/base/python/methods/python_methods_app.cc +++ b/src/ballistica/base/python/methods/python_methods_app.cc @@ -47,7 +47,11 @@ static PyMethodDef PyAppNameDef = { static auto PyRunApp(PyObject* self) -> PyObject* { BA_PYTHON_TRY; - printf("WOULD RUN!\n"); + FatalError("NOT WORKING YET; COME BACK SOON."); + + assert(g_base); + g_base->RunAppToCompletion(); + Py_RETURN_NONE; BA_PYTHON_CATCH; } diff --git a/src/ballistica/core/core.cc b/src/ballistica/core/core.cc index 8edfda7c..c5db9aa0 100644 --- a/src/ballistica/core/core.cc +++ b/src/ballistica/core/core.cc @@ -146,6 +146,14 @@ void CoreFeatureSet::PostInit() { // Grab whatever Python stuff we use. python->ImportPythonObjs(); + // Normally we wait until babase is imported to push early logs through to + // Python (so that our log handling system is fully bootstrapped), but + // technically we can push our log calls out to Python any time now since + // we grabbed the logging calls above. Do so immediately here if asked. + if (!g_core->core_config().hold_early_logs) { + python->EnablePythonLoggingCalls(); + } + // FIXME: MOVE THIS TO A RUN_APP_TO_COMPLETION() SORT OF PLACE. // For now it does the right thing here since all we have is monolithic // builds but this will need to account for more situations later. diff --git a/src/ballistica/core/python/core_python.cc b/src/ballistica/core/python/core_python.cc index 12fe711a..bd764788 100644 --- a/src/ballistica/core/python/core_python.cc +++ b/src/ballistica/core/python/core_python.cc @@ -127,8 +127,7 @@ void CorePython::EnablePythonLoggingCalls() { assert(objs().Exists(ObjID::kLoggingErrorCall)); assert(objs().Exists(ObjID::kLoggingCriticalCall)); - // Now that we've grabbed Python logging calls above, we can push any - // early log calls along to Python. They're no longer our problem. + // Push any early log calls we've been holding on to along to Python. { std::scoped_lock lock(early_log_lock_); python_logging_calls_enabled_ = true; @@ -140,21 +139,12 @@ void CorePython::EnablePythonLoggingCalls() { } void CorePython::ImportPythonObjs() { - // Define a few calls we can use for environment setup. - - // Grab core stuff that we might need before our _babase module gets spun up - // (which is when all the stuff in binding_base gets fetched). - // Note: Binding .inc files expect 'ObjID' and 'objs_' to be defined. + // Grab core Python objs we use. #include "ballistica/core/mgen/pyembed/binding_core.inc" - // Normally we wait until babase is imported to push early logs through to - // Python (so that our log handling is fully bootstrapped), but technically - // we can push things out to Python any time now since we grabbed the logging - // calls above. Do so if asked. - if (!g_core->core_config().hold_early_logs) { - EnablePythonLoggingCalls(); - } - + // Also grab a few things we define in env.inc. Normally this sort of + // thing would go in _hooks.py in our Python package, but because we are + // core we don't have one, so we have to do it via inline code. { #include "ballistica/core/mgen/pyembed/env.inc" auto ctx = PythonRef(PyDict_New(), PythonRef::kSteal); diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index a664c9e0..0a6019df 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 = 21071; +const int kEngineBuildNumber = 21072; const char* kEngineVersion = "1.7.20"; auto MonolithicMain(const core::CoreConfig& core_config) -> int { diff --git a/src/ballistica/shared/foundation/fatal_error.cc b/src/ballistica/shared/foundation/fatal_error.cc index 748eb1ba..0c3373b7 100644 --- a/src/ballistica/shared/foundation/fatal_error.cc +++ b/src/ballistica/shared/foundation/fatal_error.cc @@ -37,7 +37,7 @@ void FatalError::ReportFatalError(const std::string& message, // immediately in order to get the debugger's attention. if (g_core && g_core->core_config().debugger_attached) { if (!message.empty()) { - printf("FATAL ERROR: %s\n", message.c_str()); + printf("FATAL ERROR (debugger mode): %s\n", message.c_str()); fflush(stdout); } abort(); @@ -78,6 +78,8 @@ void FatalError::ReportFatalError(const std::string& message, + "\nCPP-STACK-TRACE-END"); } delete trace; + } else { + logmsg += "\n(CPP-STACK-TRACE-UNAVAILABLE)"; } } } From 75a236c897474a7835e8228443acb506ac015e37 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 8 Jun 2023 12:52:42 -0700 Subject: [PATCH 2/7] fixed crash drawing terrain node with no texture set --- .efrocachemap | 40 +++++++++---------- CHANGELOG.md | 3 +- src/assets/ba_data/python/baenv.py | 2 +- .../platform/windows/core_platform_windows.cc | 14 ------- src/ballistica/scene_v1/node/terrain_node.cc | 4 +- src/ballistica/shared/ballistica.cc | 2 +- 6 files changed, 27 insertions(+), 38 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 08a98c82..783083ad 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/1b/b8/532a6971b2fcde399db71380f199", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/e1/c6/129b00c453204caf4b527a1e7bf5", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ec/2c/9b26c894d69e4f78b29d3e7c14ca", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/26/f9/d6f77a2ed0a847b3cc3cbab51223", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/31/42/26c9e0ead4d1b17960834c0e9a17", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/7b/25/e55d4e007315295d9fbbc19ff3f1", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/91/c3/78db3cff1c37f2028f4cf1dbb435", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/76/34/c5e097bfddd0379b92d9aa1ef42e", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/11/c7/b8c4ce04f15b6ee2a8fe34ed9a8c", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/0c/15/6da0ded38e64fed5778b15a9dc58", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/1d/6d/e7e3ee414c73f2857531de2a362a", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/1d/76/b762b765eaf6c85ca7346cda68ed", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/1c/2b/da531e1c3f5a0778c97175a3ac84", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/da/c7/c2829f0e2aaf47ff706d6cfadb6a", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ad/d0/51afd6f99890fb7a3dbb05ca9d14", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b9/29/d7e921e6239e27ecc39d2dfe9910", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/49/c8/cf436fc6e64192bfc5b23393eeab", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/34/b0/8592d685b1a2c85308ede3494746", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/41/d2/6923abda66b4b7f8c73e8a9ef78b", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/04/30/75863a1df70641893045cd4bf8af", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/76/e2/95ac7cceb6e94fd34acc7c350263", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/54/b3/9c381ed5dda3c399c7b955fa8d50", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a6/77/a0efaffa066d6b00bc996b56636b", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ee/51/d753711059b5438da91fe1ac03db", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/07/5a/2cc7650c428543f5a33013bfceeb", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/1c/38/2665b9bd9bac14ad73ef4986acd7", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/fc/18/11baef9fa7f78211da59e1396fc9", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/5a/fc/fcf4c33bde143d92cfafbdf16ee3", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/83/02/b567d1fd06d21863ba125fd1ae22", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/fc/64/129a84c24ee5074d3b1a7c0d3440", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ad/d2/87c0898b21b23d8d54a16e44a2fd", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/89/8f/27cd935153e755742f79753ce9a0", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/cb/46/21e3e231e46b9a694747bb060333", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/db/e8/73eb4dc951795c665c946c943ebb", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/e1/b6/941774ba089254534ac54612a842", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d0/86/9cb45fca207b9b43db1beee48514", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/21/a0/13b7bb057fc1d351427127f5b001", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/8d/63/657b92f76a646cb7cace9c467c26", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/9c/e0/ef535d0fc11b943eced693b1465d", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/86/f0/6a02c50487ba42a86f4bd173e54c", "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/58/55/b6ae6dd4f3615fa87bb170a43233", "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/b9/f8/37285d0ced7794a82534d13c33ac", "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/c7/cc/0c5f0afbfa0ddabaea8d5838562a", diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e62928f..608ae192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.20 (build 21072, api 8, 2023-06-08) +### 1.7.20 (build 21073, api 8, 2023-06-08) - 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 @@ -299,6 +299,7 @@ (thanks for the heads- up SEBASTIAN2059) - (build 21070) Fixed an issue where teams series would incorrectly end after 1 round (thanks for the heads up SEBASTIAN2059) +- (build 21072) Fixed a crash drawing a terrain node with no texture set. ### 1.7.19 (build 20997, api 7, 2023-01-19) diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 016a6554..f4b21301 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -28,7 +28,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21072 +TARGET_BALLISTICA_BUILD = 21073 TARGET_BALLISTICA_VERSION = '1.7.20' _g_env_config: EnvConfig | None = None diff --git a/src/ballistica/core/platform/windows/core_platform_windows.cc b/src/ballistica/core/platform/windows/core_platform_windows.cc index 0cfaa3e7..1fca333f 100644 --- a/src/ballistica/core/platform/windows/core_platform_windows.cc +++ b/src/ballistica/core/platform/windows/core_platform_windows.cc @@ -704,20 +704,6 @@ void CorePlatformWindows::DisplayLog(const std::string& name, LogLevel level, OutputDebugString(UTF8Decode(msg).c_str()); } -// (The default SDL handler now covers us) -// bool CorePlatformWindows::BlockingFatalErrorDialog(const std::string& -// message) { -// if (HeadlessMode()) { -// return CorePlatform::BlockingFatalErrorDialog(message); -// } -// MessageBoxA(nullptr, (message.c_str()), "BallisticaKit", -// MB_ICONERROR | MB_OK); - -// // Our message-box call is blocking so we can return false here -// // and let the app self-terminate at this point. -// return false; -// } - auto CorePlatformWindows::DoGetDataDirectoryMonolithicDefault() -> std::string { wchar_t sz_file_name[MAX_PATH + 1]; GetModuleFileName(nullptr, sz_file_name, MAX_PATH + 1); diff --git a/src/ballistica/scene_v1/node/terrain_node.cc b/src/ballistica/scene_v1/node/terrain_node.cc index 06a2d009..ccf6f3ca 100644 --- a/src/ballistica/scene_v1/node/terrain_node.cc +++ b/src/ballistica/scene_v1/node/terrain_node.cc @@ -229,7 +229,9 @@ void TerrainNode::Draw(base::FrameDef* frame_def) { : background_ ? frame_def->beauty_pass_bg() : frame_def->beauty_pass()); c.SetWorldSpace(true); - c.SetTexture(color_texture_->texture_data()); + if (color_texture_.Exists()) { + c.SetTexture(color_texture_->texture_data()); + } if (lighting_) { c.SetLightShadow(base::LightShadowType::kTerrain); } else { diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 0a6019df..5812a726 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 = 21072; +const int kEngineBuildNumber = 21073; const char* kEngineVersion = "1.7.20"; auto MonolithicMain(const core::CoreConfig& core_config) -> int { From 95815353cc0cd4e96cf3a295c951bee37253b874 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 8 Jun 2023 15:16:35 -0700 Subject: [PATCH 3/7] implemented stack traces on windows --- .efrocachemap | 56 +++---- CHANGELOG.md | 5 +- src/assets/ba_data/python/baenv.py | 2 +- src/ballistica/core/core.cc | 8 +- src/ballistica/core/platform/core_platform.cc | 2 +- src/ballistica/core/platform/core_platform.h | 2 +- .../platform/windows/core_platform_windows.cc | 153 ++++++++++++++++++ .../platform/windows/core_platform_windows.h | 11 ++ src/ballistica/shared/ballistica.cc | 2 +- src/ballistica/shared/foundation/exception.cc | 2 +- src/ballistica/ui_v1/ui_v1.h | 2 +- tools/batools/project/_checks.py | 6 +- 12 files changed, 211 insertions(+), 40 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 783083ad..54f52996 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/76/e2/95ac7cceb6e94fd34acc7c350263", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/54/b3/9c381ed5dda3c399c7b955fa8d50", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a6/77/a0efaffa066d6b00bc996b56636b", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ee/51/d753711059b5438da91fe1ac03db", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/07/5a/2cc7650c428543f5a33013bfceeb", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/1c/38/2665b9bd9bac14ad73ef4986acd7", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/fc/18/11baef9fa7f78211da59e1396fc9", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/5a/fc/fcf4c33bde143d92cfafbdf16ee3", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/83/02/b567d1fd06d21863ba125fd1ae22", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/fc/64/129a84c24ee5074d3b1a7c0d3440", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/ad/d2/87c0898b21b23d8d54a16e44a2fd", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/89/8f/27cd935153e755742f79753ce9a0", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/cb/46/21e3e231e46b9a694747bb060333", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/db/e8/73eb4dc951795c665c946c943ebb", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/e1/b6/941774ba089254534ac54612a842", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d0/86/9cb45fca207b9b43db1beee48514", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/21/a0/13b7bb057fc1d351427127f5b001", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/8d/63/657b92f76a646cb7cace9c467c26", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/9c/e0/ef535d0fc11b943eced693b1465d", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/86/f0/6a02c50487ba42a86f4bd173e54c", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/fa/78/a214be11993d36a52192d87ec637", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/37/b3/419b2996dcf20e83d2550512ede5", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/fc/32/72b0b40b06ecca15e7da66180553", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/8c/8e/692af6872e7a247793d88d9ebf99", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/1c/c6/59084601f9a9ab70c673a8782c5a", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/f4/44/aee3980f4d679d89145abcdc4146", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/99/6e/bb06e27cf507f1ac597cd88ddf99", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/e1/7b/811ab8937a398e7d40c85a22cc0e", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/1b/73/543b3d40a8ab5ec65f549d575736", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/f0/e1/b305a86d0ee307b497b19eb7ae18", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/14/5e/6e8bfa5870766ab3cb0bc1363fc1", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/5a/24/8779125082977f75de7aeac097ca", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/c5/ab/969f814415316f5a32b21b5ec95e", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/63/7a/fb8c34f54070613f56c5ecdb5d0a", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/df/a6/4406c159af542d841a9a598a50d2", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/17/0b/052ded44e214490afb11370e548c", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/49/1f/f9bf566efdd357185713ee2db3f7", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/a5/6f/3f16a4bc453b29f2934269afe369", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/b6/93/f1daebdde56b97167ac43c6e983c", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/51/7c/833fcba248f23598eb606ec1e366", "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/58/55/b6ae6dd4f3615fa87bb170a43233", "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/b9/f8/37285d0ced7794a82534d13c33ac", "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/c7/cc/0c5f0afbfa0ddabaea8d5838562a", @@ -4108,14 +4108,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/96/2e/1b0ba43fe24fe9cc223a434db647", "build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/f3/83/581b7df96f6516032a0747b83e15", "build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/6a/6d/7aaf7617929eeff41bc5a574e6c8", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/20/f0/4e9e3644c559e00816a8621a8987", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/7c/39/5390a4370b1c3a931a84abf6f477", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/f8/ec/e98d729c3d66249a1e11aa26af2d", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/62/9c/2c38890b97307365059b162abe51", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/90/81/4d46be8eb3992b016a7c82f5766a", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/18/09/af24159486d0253f900e262d9fd9", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/a8/f5/68bb806fdee3a4694352d1e03a60", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/ee/96/8259473f7ed61dfdb8dd8af6f845", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/bf/67/b2e47d165f67487a411c10ec6761", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/68/3f/b02ee9d51503a71abe3fc9a160a8", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/87/9b/63f4ed1cef6e7214b69c06962d2c", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/ee/64/6a17dc184bac9e42613a2228e210", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/a3/7c/607018f0aa7f918a978d8d9719e2", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/14/49/7af3c9043dadbb78e5d4467e471b", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/15/a5/28c86995a7171bd8b5d0291da22f", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/93/f5/0ad008b1910c9a630e47d4077d83", "src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/52/c6/c11130af7b10d6c0321add5518fa", "src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/38/c3/1dedd5e74f2508efc5974c8815a1", "src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/75/9f/bcf597b362c9f2480cb348188bdd", diff --git a/CHANGELOG.md b/CHANGELOG.md index 608ae192..41ccdb03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.20 (build 21073, api 8, 2023-06-08) +### 1.7.20 (build 21074, api 8, 2023-06-08) - 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 @@ -300,6 +300,9 @@ - (build 21070) Fixed an issue where teams series would incorrectly end after 1 round (thanks for the heads up SEBASTIAN2059) - (build 21072) Fixed a crash drawing a terrain node with no texture set. +- (build 21073) Stack traces are now implemented under windows so should show up + for fatal errors and whatnot. Also fatal error logging now mentions when stack + traces are not available. ### 1.7.19 (build 20997, api 7, 2023-01-19) diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index f4b21301..380acbf4 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -28,7 +28,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21073 +TARGET_BALLISTICA_BUILD = 21074 TARGET_BALLISTICA_VERSION = '1.7.20' _g_env_config: EnvConfig | None = None diff --git a/src/ballistica/core/core.cc b/src/ballistica/core/core.cc index c5db9aa0..1ae694ab 100644 --- a/src/ballistica/core/core.cc +++ b/src/ballistica/core/core.cc @@ -123,10 +123,10 @@ void CoreFeatureSet::PostInit() { // We can use it to make error messages/etc. more pretty by stripping out // all but sub-project paths. const char* f = __FILE__; - auto* f_end = strstr( - f, "src" BA_DIRSLASH "ballistica" BA_DIRSLASH "app" BA_DIRSLASH "app.cc"); - if (!f) { - Log(LogLevel::kWarning, "Unable to calc project dir from __FILE__."); + auto* f_end = strstr(f, "src" BA_DIRSLASH "ballistica" BA_DIRSLASH + "core" BA_DIRSLASH "core.cc"); + if (!f_end) { + Log(LogLevel::kWarning, "Unable to calc build source dir from __FILE__."); } else { build_src_dir_ = std::string(f).substr(0, f_end - f); } diff --git a/src/ballistica/core/platform/core_platform.cc b/src/ballistica/core/platform/core_platform.cc index f13e1916..c8b7911b 100644 --- a/src/ballistica/core/platform/core_platform.cc +++ b/src/ballistica/core/platform/core_platform.cc @@ -1078,7 +1078,7 @@ class PlatformStackTraceExecInfo : public PlatformStackTrace { } } - auto copy() const noexcept -> PlatformStackTrace* override { + auto Copy() const noexcept -> PlatformStackTrace* override { try { auto s = new PlatformStackTraceExecInfo(*this); diff --git a/src/ballistica/core/platform/core_platform.h b/src/ballistica/core/platform/core_platform.h index e5f3cc95..06c459e2 100644 --- a/src/ballistica/core/platform/core_platform.h +++ b/src/ballistica/core/platform/core_platform.h @@ -30,7 +30,7 @@ class PlatformStackTrace { // Should return a copy of itself allocated via new() (or nullptr if not // possible). - virtual auto copy() const noexcept -> PlatformStackTrace* = 0; + virtual auto Copy() const noexcept -> PlatformStackTrace* = 0; }; /// This class attempts to abstract away most platform-specific diff --git a/src/ballistica/core/platform/windows/core_platform_windows.cc b/src/ballistica/core/platform/windows/core_platform_windows.cc index 1fca333f..d3d4d4ff 100644 --- a/src/ballistica/core/platform/windows/core_platform_windows.cc +++ b/src/ballistica/core/platform/windows/core_platform_windows.cc @@ -12,6 +12,11 @@ #include #include +/* clang-format off */ +// Builds fail if this is further up. +#include +/* clang-format on */ + #pragma comment(lib, "Rpcrt4.lib") #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "iphlpapi.lib") @@ -20,7 +25,9 @@ #else #pragma comment(lib, "python311.lib") #endif +#pragma comment(lib, "DbgHelp.lib") +// GUI Only Stuff. #if !BA_HEADLESS_BUILD #pragma comment(lib, "libogg.lib") #pragma comment(lib, "libvorbis.lib") @@ -39,6 +46,108 @@ namespace ballistica::core { +static const int kTraceMaxStackFrames{256}; +static const int kTraceMaxFunctionNameLength{1024}; + +class WinStackTrace : public PlatformStackTrace { + public: + explicit WinStackTrace(CorePlatformWindows* platform) : platform_{platform} { + number_of_frames_ = + CaptureStackBackTrace(0, kTraceMaxStackFrames, stack_, NULL); + } + + // Return a human readable version of the trace (with symbolification if + // available). + auto GetDescription() noexcept -> std::string { + return platform_->GetWinStackTraceDescription(this); + } + + // Should return a copy of itself allocated via new() (or nullptr if not + // possible). + auto Copy() const noexcept -> PlatformStackTrace* override { + try { + auto s = new WinStackTrace(*this); + + // Vanilla copy constructor should do the right thing here. + assert(s->number_of_frames_ == number_of_frames_ + && memcmp(s->stack_, stack_, sizeof(stack_)) == 0); + return s; + } catch (const std::exception&) { + // If this is failing we're in big trouble anyway. + return nullptr; + } + } + + auto number_of_frames() const { return number_of_frames_; } + auto* stack() const { return stack_; } + + private: + CorePlatformWindows* platform_; + WORD number_of_frames_{}; + void* stack_[kTraceMaxStackFrames]; +}; + +auto CorePlatformWindows::GetWinStackTraceDescription( + WinStackTrace* stack_trace) -> std::string { + try { + std::string out; + + // Win docs say this is not thread safe so limit to one at a time. + std::scoped_lock lock(win_stack_mutex_); + + // Docs say to do this only once. + if (!win_sym_inited_) { + win_sym_process_ = GetCurrentProcess(); + SymInitialize(win_sym_process_, NULL, TRUE); + win_sym_inited_ = true; + } + + char buf[sizeof(SYMBOL_INFO) + + (kTraceMaxFunctionNameLength - 1) * sizeof(TCHAR)]; + SYMBOL_INFO* symbol = reinterpret_cast(buf); + symbol->MaxNameLen = kTraceMaxFunctionNameLength; + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + DWORD displacement; + IMAGEHLP_LINE64 line; + line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); + + std::string build_src_dir = g_core ? g_core->build_src_dir() : ""; + + char linebuf[kTraceMaxFunctionNameLength + 128]; + for (int i = 0; i < stack_trace->number_of_frames(); i++) { + DWORD64 address = (DWORD64)(stack_trace->stack()[i]); + SymFromAddr(win_sym_process_, address, NULL, symbol); + if (SymGetLineFromAddr64(win_sym_process_, address, &displacement, + &line)) { + const char* filename = line.FileName; + if (!build_src_dir.empty() + && !strncmp(filename, build_src_dir.c_str(), + build_src_dir.size())) { + filename += build_src_dir.size(); + } + snprintf(linebuf, sizeof(linebuf), + "%-3d %s in %s: line: %lu: address: 0x%p\n", i, symbol->Name, + filename, line.LineNumber, + reinterpret_cast(symbol->Address)); + } else { + snprintf(linebuf, sizeof(linebuf), + "SymGetLineFromAddr64 returned error code %lu.\n", + GetLastError()); + snprintf(linebuf, sizeof(linebuf), "%-3d %s, address 0x%p.\n", i, + symbol->Name, reinterpret_cast(symbol->Address)); + } + out += linebuf; + } + return out; + } catch (const std::exception&) { + return "stack-trace construction failed."; + } +} + +auto CorePlatformWindows::GetStackTrace() -> PlatformStackTrace* { + return new WinStackTrace(this); +} + // Convert a wide Unicode string to an UTF8 string. auto CorePlatformWindows::UTF8Encode(const std::wstring& wstr) -> std::string { if (wstr.empty()) return std::string(); @@ -61,10 +170,54 @@ auto CorePlatformWindows::UTF8Decode(const std::string& str) -> std::wstring { return wstr; } +#define TRACE_MAX_STACK_FRAMES 256 +#define TRACE_MAX_FUNCTION_NAME_LENGTH 1024 + +// int printStackTrace() { +// void* stack[TRACE_MAX_STACK_FRAMES]; +// if (!win_sym_inited_) { +// win_sym_process_ = GetCurrentProcess(); +// SymInitialize(win_sym_process_, NULL, TRUE); +// win_sym_inited_ = true; +// } +// WORD numberOfFrames = +// CaptureStackBackTrace(0, TRACE_MAX_STACK_FRAMES, stack, NULL); + +// char buf[sizeof(SYMBOL_INFO) +// + (TRACE_MAX_FUNCTION_NAME_LENGTH - 1) * sizeof(TCHAR)]; +// SYMBOL_INFO* symbol = (SYMBOL_INFO*)buf; +// symbol->MaxNameLen = TRACE_MAX_FUNCTION_NAME_LENGTH; +// symbol->SizeOfStruct = sizeof(SYMBOL_INFO); +// DWORD displacement; +// IMAGEHLP_LINE64 line; +// line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); +// for (int i = 0; i < numberOfFrames; i++) { +// DWORD64 address = (DWORD64)(stack[i]); +// SymFromAddr(win_sym_process_, address, NULL, symbol); +// if (SymGetLineFromAddr64(win_sym_process_, address, &displacement, +// &line)) { +// printf("\tat %s in %s: line: %lu: address: 0x%0X\n", symbol->Name, +// line.FileName, line.LineNumber, symbol->Address); +// } else { +// printf("\tSymGetLineFromAddr64 returned error code %lu.\n", +// GetLastError()); +// printf("\tat %s, address 0x%0X.\n", symbol->Name, symbol->Address); +// } +// } +// return 0; +// } + CorePlatformWindows::CorePlatformWindows() { // We should be built in unicode mode. assert(sizeof(TCHAR) == 2); + // printStackTrace(); + + // auto* testtrace = new WinStackTrace(this); + // printf("WINTRACE:\n%s", testtrace->GetDescription().c_str()); + // printf("WOOHOO!\n"); + // fflush(stdout); + // Need to init winsock immediately since we use it for // threading/logging/etc. { diff --git a/src/ballistica/core/platform/windows/core_platform_windows.h b/src/ballistica/core/platform/windows/core_platform_windows.h index ac14b3ff..15a045ee 100644 --- a/src/ballistica/core/platform/windows/core_platform_windows.h +++ b/src/ballistica/core/platform/windows/core_platform_windows.h @@ -4,6 +4,7 @@ #define BALLISTICA_CORE_PLATFORM_WINDOWS_CORE_PLATFORM_WINDOWS_H_ #if BA_OSTYPE_WINDOWS +#include #include #include @@ -11,6 +12,8 @@ namespace ballistica::core { +class WinStackTrace; + class CorePlatformWindows : public CorePlatform { public: CorePlatformWindows(); @@ -18,6 +21,7 @@ class CorePlatformWindows : public CorePlatform { static auto UTF8Encode(const std::wstring& wstr) -> std::string; static auto UTF8Decode(const std::string& str) -> std::wstring; + auto GetStackTrace() -> PlatformStackTrace* override; auto GetDeviceV1AccountUUIDPrefix() -> std::string override { return "w"; } auto GetDeviceUUIDInputs() -> std::list override; auto GenerateUUID() -> std::string override; @@ -53,6 +57,13 @@ class CorePlatformWindows : public CorePlatform { auto GetPlatformName() -> std::string override; auto GetSubplatformName() -> std::string override; bool have_stdin_stdout_ = false; + + auto GetWinStackTraceDescription(WinStackTrace* stack_trace) -> std::string; + + private: + std::mutex win_stack_mutex_; + bool win_sym_inited_{}; + void* win_sym_process_{}; }; } // namespace ballistica::core diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 5812a726..db815e43 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 = 21073; +const int kEngineBuildNumber = 21074; const char* kEngineVersion = "1.7.20"; auto MonolithicMain(const core::CoreConfig& core_config) -> int { diff --git a/src/ballistica/shared/foundation/exception.cc b/src/ballistica/shared/foundation/exception.cc index 23a2277b..3b5abc9e 100644 --- a/src/ballistica/shared/foundation/exception.cc +++ b/src/ballistica/shared/foundation/exception.cc @@ -43,7 +43,7 @@ Exception::Exception(const Exception& other) noexcept { full_description_ = other.full_description_; python_type_ = other.python_type_; if (other.stack_trace_) { - stack_trace_ = other.stack_trace_->copy(); + stack_trace_ = other.stack_trace_->Copy(); } } catch (const std::exception&) { // Hmmm not sure what we should do if this happens; diff --git a/src/ballistica/ui_v1/ui_v1.h b/src/ballistica/ui_v1/ui_v1.h index 67503861..2227c200 100644 --- a/src/ballistica/ui_v1/ui_v1.h +++ b/src/ballistica/ui_v1/ui_v1.h @@ -18,7 +18,7 @@ class CoreFeatureSet; } namespace ballistica::base { class BaseFeatureSet; -class WidgetMessage; +struct WidgetMessage; } // namespace ballistica::base namespace ballistica::ui_v1 { diff --git a/tools/batools/project/_checks.py b/tools/batools/project/_checks.py index 337c0aa6..df396736 100755 --- a/tools/batools/project/_checks.py +++ b/tools/batools/project/_checks.py @@ -132,7 +132,11 @@ def _get_namespace_info(lines: list[str], index: int) -> tuple[str, bool]: if lines[index].startswith('}'): return name, True if not ( - lines[index].startswith('class ') and lines[index].endswith(';') + ( + lines[index].startswith('class ') + or lines[index].startswith('struct ') + ) + and lines[index].endswith(';') ): # Found a non-predeclare statement return name, False From 01064e79609f339c8344538d789d6eb24fe3d705 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 8 Jun 2023 15:54:08 -0700 Subject: [PATCH 4/7] added babase.native_stack_trace() --- .efrocachemap | 56 +++++++++---------- CHANGELOG.md | 4 +- src/assets/ba_data/python/babase/__init__.py | 2 + src/assets/ba_data/python/baenv.py | 2 +- .../python/methods/python_methods_misc.cc | 32 +++++++++++ src/ballistica/core/platform/core_platform.cc | 4 +- src/ballistica/core/platform/core_platform.h | 10 ++-- .../platform/windows/core_platform_windows.cc | 8 +-- .../platform/windows/core_platform_windows.h | 2 +- src/ballistica/shared/ballistica.cc | 2 +- src/ballistica/shared/foundation/exception.cc | 2 +- .../shared/foundation/fatal_error.cc | 2 +- 12 files changed, 82 insertions(+), 44 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 54f52996..861a0a5e 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/fa/78/a214be11993d36a52192d87ec637", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/37/b3/419b2996dcf20e83d2550512ede5", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/fc/32/72b0b40b06ecca15e7da66180553", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/8c/8e/692af6872e7a247793d88d9ebf99", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/1c/c6/59084601f9a9ab70c673a8782c5a", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/f4/44/aee3980f4d679d89145abcdc4146", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/99/6e/bb06e27cf507f1ac597cd88ddf99", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/e1/7b/811ab8937a398e7d40c85a22cc0e", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/1b/73/543b3d40a8ab5ec65f549d575736", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/f0/e1/b305a86d0ee307b497b19eb7ae18", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/14/5e/6e8bfa5870766ab3cb0bc1363fc1", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/5a/24/8779125082977f75de7aeac097ca", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/c5/ab/969f814415316f5a32b21b5ec95e", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/63/7a/fb8c34f54070613f56c5ecdb5d0a", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/df/a6/4406c159af542d841a9a598a50d2", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/17/0b/052ded44e214490afb11370e548c", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/49/1f/f9bf566efdd357185713ee2db3f7", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/a5/6f/3f16a4bc453b29f2934269afe369", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/b6/93/f1daebdde56b97167ac43c6e983c", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/51/7c/833fcba248f23598eb606ec1e366", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/6b/af/77143d27fc8d029928c5e1bb10c7", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/85/76/121d40e717c2de145d6dca273642", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/1c/23/18d7ef96170aa3062abb354f2273", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/12/a9/99703794b4cc389f320721d94aae", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/80/32/2efd24f59072f1cb879b0f200655", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/21/46/cef78dedb759770ff165dae9c926", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/84/fc/0b6d71d75f4bd63f62fa7b980dbb", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/eb/81/93908c54010e63084ac763e65fed", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/f7/06/a66e097cd58666d098a38b700bdc", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/e1/f9/8fcb8ff917dc0b2d2f06d8e43fd2", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c4/8c/a7b9933f30c839ec5b9ad46e6584", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d2/0f/7b312ae1f670cc9144208303e61c", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/c1/dd/c7e2c05c76b12bbe4b3ff6a2461a", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/74/6c/c2283283605425d3a3c8b60adbb8", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/e6/77/ecf7fc23cb0bed38be8f1779dd02", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d7/21/776c71a0d8536ef13186c053cde4", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/ca/a0/40a94450ef233e76c6d0a34164b1", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/9b/0e/ac0aaf7253be3e379c8e32b0d29f", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/71/43/0f2794f1da00b2169b3e4652341e", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/b0/f5/8539056667c96d4bbe170073f74e", "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/58/55/b6ae6dd4f3615fa87bb170a43233", "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/b9/f8/37285d0ced7794a82534d13c33ac", "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/c7/cc/0c5f0afbfa0ddabaea8d5838562a", @@ -4108,14 +4108,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/96/2e/1b0ba43fe24fe9cc223a434db647", "build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/f3/83/581b7df96f6516032a0747b83e15", "build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/6a/6d/7aaf7617929eeff41bc5a574e6c8", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/bf/67/b2e47d165f67487a411c10ec6761", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/68/3f/b02ee9d51503a71abe3fc9a160a8", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/87/9b/63f4ed1cef6e7214b69c06962d2c", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/ee/64/6a17dc184bac9e42613a2228e210", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/a3/7c/607018f0aa7f918a978d8d9719e2", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/14/49/7af3c9043dadbb78e5d4467e471b", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/15/a5/28c86995a7171bd8b5d0291da22f", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/93/f5/0ad008b1910c9a630e47d4077d83", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/55/c6/3e32ba9707e85f406ea329a00c21", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/4f/40/fc458ef6f3d7bcffb1f2998986d4", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/78/56/b042fdc52d047dce785cef6c1cb1", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/83/7a/33e42ec87ed9b0f3d42ae196efbf", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/91/24/0b00221d14389ae8ae7bd256f1e2", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/05/01/0c0f852d345d6b0cc64d254625bd", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/43/6b/d56519105aa22a01bc910f08c959", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/f7/fc/e25e5116bca1e0f647b725316fc0", "src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/52/c6/c11130af7b10d6c0321add5518fa", "src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/38/c3/1dedd5e74f2508efc5974c8815a1", "src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/75/9f/bcf597b362c9f2480cb348188bdd", diff --git a/CHANGELOG.md b/CHANGELOG.md index 41ccdb03..d5c2bcf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.20 (build 21074, api 8, 2023-06-08) +### 1.7.20 (build 21075, api 8, 2023-06-08) - 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 @@ -303,6 +303,8 @@ - (build 21073) Stack traces are now implemented under windows so should show up for fatal errors and whatnot. Also fatal error logging now mentions when stack traces are not available. +- (build 21074) Added `babase.native_stack_trace()` to fetch native stack traces + as strings. ### 1.7.19 (build 20997, api 7, 2023-01-19) diff --git a/src/assets/ba_data/python/babase/__init__.py b/src/assets/ba_data/python/babase/__init__.py index 2fd7602b..2b6c4876 100644 --- a/src/assets/ba_data/python/babase/__init__.py +++ b/src/assets/ba_data/python/babase/__init__.py @@ -34,6 +34,7 @@ from _babase import ( clipboard_get_text, clipboard_set_text, in_logic_thread, + native_stack_trace, ) from babase._appintent import AppIntent, AppIntentDefault, AppIntentExec @@ -167,6 +168,7 @@ __all__ = [ 'AppMode', 'AppSubsystem', 'screenmessage', + 'native_stack_trace', ] # We want stuff to show up as babase.Foo instead of babase._sub.Foo. diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 380acbf4..bd103bf5 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -28,7 +28,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21074 +TARGET_BALLISTICA_BUILD = 21075 TARGET_BALLISTICA_VERSION = '1.7.20' _g_env_config: EnvConfig | None = None diff --git a/src/ballistica/base/python/methods/python_methods_misc.cc b/src/ballistica/base/python/methods/python_methods_misc.cc index 9fccda69..47e553fa 100644 --- a/src/ballistica/base/python/methods/python_methods_misc.cc +++ b/src/ballistica/base/python/methods/python_methods_misc.cc @@ -1383,6 +1383,37 @@ static PyMethodDef PyUnlockAllInputDef = { "Resumes normal keyboard, mouse, and gamepad event processing.", }; +// --------------------------- native_stack_trace ------------------------------ + +static auto PyNativeStackTrace(PyObject* self) -> PyObject* { + BA_PYTHON_TRY; + assert(g_core); + auto* trace = g_core->platform->GetStackTrace(); + if (!trace) { + Py_RETURN_NONE; + } + auto out = trace->FormatForDisplay(); + delete trace; + return PyUnicode_FromString(out.c_str()); + Py_RETURN_FALSE; + BA_PYTHON_CATCH; +} + +static PyMethodDef PyNativeStackTraceDef = { + "native_stack_trace", // name + (PyCFunction)PyNativeStackTrace, // method + METH_NOARGS, // flags + + "native_stack_trace() -> str | None\n" + "\n" + "Return a native stack trace as a string, or None if not available.\n" + "\n" + "Category: **General Utility Functions**\n" + "\n" + "Stack traces contain different data and formatting across platforms.\n" + "Only use them for debugging.", +}; + // ----------------------------------------------------------------------------- auto PythonMethodsMisc::GetMethods() -> std::vector { @@ -1436,6 +1467,7 @@ auto PythonMethodsMisc::GetMethods() -> std::vector { PySetUpSigIntDef, PyGetSimpleSoundDef, PyHasTouchScreenDef, + PyNativeStackTraceDef, }; } diff --git a/src/ballistica/core/platform/core_platform.cc b/src/ballistica/core/platform/core_platform.cc index c8b7911b..f1ff0f34 100644 --- a/src/ballistica/core/platform/core_platform.cc +++ b/src/ballistica/core/platform/core_platform.cc @@ -1058,10 +1058,10 @@ class PlatformStackTraceExecInfo : public PlatformStackTrace { // The stack trace should capture the stack state immediately upon // construction but should do the bare minimum amount of work to store it. Any // expensive operations such as symbolification should be deferred until - // GetDescription(). + // FormatForDisplay(). PlatformStackTraceExecInfo() { nsize_ = backtrace(array_, kMaxStackLevels); } - auto GetDescription() noexcept -> std::string override { + auto FormatForDisplay() noexcept -> std::string override { try { std::string s; char** symbols = backtrace_symbols(array_, nsize_); diff --git a/src/ballistica/core/platform/core_platform.h b/src/ballistica/core/platform/core_platform.h index 06c459e2..24d0fc4a 100644 --- a/src/ballistica/core/platform/core_platform.h +++ b/src/ballistica/core/platform/core_platform.h @@ -19,14 +19,14 @@ namespace ballistica::core { /// trace classes should capture the stack state immediately upon /// construction but should do the bare minimum amount of work to store it. /// Any expensive operations such as symbolification should be deferred -/// until GetDescription(). +/// until FormatForDisplay(). class PlatformStackTrace { public: virtual ~PlatformStackTrace() = default; // Return a human readable version of the trace (with symbolification if // available). - virtual auto GetDescription() noexcept -> std::string = 0; + virtual auto FormatForDisplay() noexcept -> std::string = 0; // Should return a copy of itself allocated via new() (or nullptr if not // possible). @@ -362,8 +362,10 @@ class CorePlatform { #pragma mark ERRORS & DEBUGGING ------------------------------------------------ - /// Should return a subclass of PlatformStackTrace allocated via new. - /// Platforms with no meaningful stack trace functionality can return nullptr. + /// Should return a subclass of PlatformStackTrace allocated via new. It + /// is up to the caller to call delete on the returned trace when done + /// with it. Platforms with no meaningful stack trace functionality can + /// return nullptr. virtual auto GetStackTrace() -> PlatformStackTrace*; // Called during stress testing. diff --git a/src/ballistica/core/platform/windows/core_platform_windows.cc b/src/ballistica/core/platform/windows/core_platform_windows.cc index d3d4d4ff..0587b49d 100644 --- a/src/ballistica/core/platform/windows/core_platform_windows.cc +++ b/src/ballistica/core/platform/windows/core_platform_windows.cc @@ -58,8 +58,8 @@ class WinStackTrace : public PlatformStackTrace { // Return a human readable version of the trace (with symbolification if // available). - auto GetDescription() noexcept -> std::string { - return platform_->GetWinStackTraceDescription(this); + auto FormatForDisplay() noexcept -> std::string { + return platform_->FormatWinStackTraceForDisplay(this); } // Should return a copy of itself allocated via new() (or nullptr if not @@ -87,7 +87,7 @@ class WinStackTrace : public PlatformStackTrace { void* stack_[kTraceMaxStackFrames]; }; -auto CorePlatformWindows::GetWinStackTraceDescription( +auto CorePlatformWindows::FormatWinStackTraceForDisplay( WinStackTrace* stack_trace) -> std::string { try { std::string out; @@ -214,7 +214,7 @@ CorePlatformWindows::CorePlatformWindows() { // printStackTrace(); // auto* testtrace = new WinStackTrace(this); - // printf("WINTRACE:\n%s", testtrace->GetDescription().c_str()); + // printf("WINTRACE:\n%s", testtrace->FormatForDisplay().c_str()); // printf("WOOHOO!\n"); // fflush(stdout); diff --git a/src/ballistica/core/platform/windows/core_platform_windows.h b/src/ballistica/core/platform/windows/core_platform_windows.h index 15a045ee..ddc1054a 100644 --- a/src/ballistica/core/platform/windows/core_platform_windows.h +++ b/src/ballistica/core/platform/windows/core_platform_windows.h @@ -58,7 +58,7 @@ class CorePlatformWindows : public CorePlatform { auto GetSubplatformName() -> std::string override; bool have_stdin_stdout_ = false; - auto GetWinStackTraceDescription(WinStackTrace* stack_trace) -> std::string; + auto FormatWinStackTraceForDisplay(WinStackTrace* stack_trace) -> std::string; private: std::mutex win_stack_mutex_; diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index db815e43..e7877cc5 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 = 21074; +const int kEngineBuildNumber = 21075; const char* kEngineVersion = "1.7.20"; auto MonolithicMain(const core::CoreConfig& core_config) -> int { diff --git a/src/ballistica/shared/foundation/exception.cc b/src/ballistica/shared/foundation/exception.cc index 3b5abc9e..8e54fc6b 100644 --- a/src/ballistica/shared/foundation/exception.cc +++ b/src/ballistica/shared/foundation/exception.cc @@ -65,7 +65,7 @@ auto Exception::what() const noexcept -> const char* { if (stack_trace_ != nullptr) { const_cast(this)->full_description_ = message_ + "\nThrown from " + thread_name_ + " thread:\n" - + stack_trace_->GetDescription(); + + stack_trace_->FormatForDisplay(); } else { const_cast(this)->full_description_ = message_; } diff --git a/src/ballistica/shared/foundation/fatal_error.cc b/src/ballistica/shared/foundation/fatal_error.cc index 0c3373b7..2e8531e4 100644 --- a/src/ballistica/shared/foundation/fatal_error.cc +++ b/src/ballistica/shared/foundation/fatal_error.cc @@ -72,7 +72,7 @@ void FatalError::ReportFatalError(const std::string& message, if (g_core && g_core->platform) { core::PlatformStackTrace* trace{g_core->platform->GetStackTrace()}; if (trace) { - std::string tracestr = trace->GetDescription(); + std::string tracestr = trace->FormatForDisplay(); if (!tracestr.empty()) { logmsg += ("\nCPP-STACK-TRACE-BEGIN:\n" + tracestr + "\nCPP-STACK-TRACE-END"); From 9f92a68ca3b0daf84d1f513d4a5a03e441f56e2f Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 8 Jun 2023 16:57:21 -0700 Subject: [PATCH 5/7] proper unicode support for windows stack traces --- .efrocachemap | 56 +++++++++---------- CHANGELOG.md | 6 +- Makefile | 4 +- src/assets/ba_data/python/babase/_apputils.py | 15 ++++- src/assets/ba_data/python/baenv.py | 2 +- .../platform/windows/core_platform_windows.cc | 14 +++-- src/ballistica/shared/ballistica.cc | 2 +- 7 files changed, 58 insertions(+), 41 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 861a0a5e..c2b9c92d 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/6b/af/77143d27fc8d029928c5e1bb10c7", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/85/76/121d40e717c2de145d6dca273642", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/1c/23/18d7ef96170aa3062abb354f2273", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/12/a9/99703794b4cc389f320721d94aae", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/80/32/2efd24f59072f1cb879b0f200655", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/21/46/cef78dedb759770ff165dae9c926", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/84/fc/0b6d71d75f4bd63f62fa7b980dbb", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/eb/81/93908c54010e63084ac763e65fed", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/f7/06/a66e097cd58666d098a38b700bdc", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/e1/f9/8fcb8ff917dc0b2d2f06d8e43fd2", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c4/8c/a7b9933f30c839ec5b9ad46e6584", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d2/0f/7b312ae1f670cc9144208303e61c", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/c1/dd/c7e2c05c76b12bbe4b3ff6a2461a", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/74/6c/c2283283605425d3a3c8b60adbb8", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/e6/77/ecf7fc23cb0bed38be8f1779dd02", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d7/21/776c71a0d8536ef13186c053cde4", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/ca/a0/40a94450ef233e76c6d0a34164b1", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/9b/0e/ac0aaf7253be3e379c8e32b0d29f", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/71/43/0f2794f1da00b2169b3e4652341e", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/b0/f5/8539056667c96d4bbe170073f74e", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/2a/bf/5ec0907b7ea2ae9ce556bfbaa977", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/b6/90/05fcb5913ac0efa57a0fe9cdb24e", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d5/9c/a39c893eb6f006a229ae677d7d1f", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/4d/bc/a448dcc9cf0de969e9ab1d723b72", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/89/6b/3661b8151586a16adb80a52c293f", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/be/7d/333edec3e78c3b0f06c7a29571d1", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/06/da/1bd3481ad7c525f537f963352131", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b8/9a/ad6ecd60091315a0aa31ca55f736", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/3a/73/6cfd57cf5a424767fd7adcf0a2db", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/53/6f/30d29940df133fa78db5b7c3298c", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b8/7c/41db8ce4cfece1553f07b891ab34", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/73/cb/2a8b7d0a208147be97198cf3a59c", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/97/56/3af6d1fb98c1e9a637f803c45aa5", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/4f/26/74f101b0d6f038070a025dfb8c0c", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a8/12/1e10c0eb9b55408e6e4d3041cbf4", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/eb/5f/50df0e0f91b1c6fe76de7c7fd048", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/85/3f/dc233392f6d02a62dcad599d264d", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/23/2e/78b07a81552a79d67631075f2632", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/26/0e/1900fb42f7080dd62e35607d6d6d", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/c9/28/c98b86c13cfabd168d8683744cf5", "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/58/55/b6ae6dd4f3615fa87bb170a43233", "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/b9/f8/37285d0ced7794a82534d13c33ac", "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/c7/cc/0c5f0afbfa0ddabaea8d5838562a", @@ -4108,14 +4108,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/96/2e/1b0ba43fe24fe9cc223a434db647", "build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/f3/83/581b7df96f6516032a0747b83e15", "build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/6a/6d/7aaf7617929eeff41bc5a574e6c8", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/55/c6/3e32ba9707e85f406ea329a00c21", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/4f/40/fc458ef6f3d7bcffb1f2998986d4", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/78/56/b042fdc52d047dce785cef6c1cb1", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/83/7a/33e42ec87ed9b0f3d42ae196efbf", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/91/24/0b00221d14389ae8ae7bd256f1e2", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/05/01/0c0f852d345d6b0cc64d254625bd", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/43/6b/d56519105aa22a01bc910f08c959", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/f7/fc/e25e5116bca1e0f647b725316fc0", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/4c/5b/e6f257859efef56c7bf8a16efb8c", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/be/ac/470e69d1b87eb9a6bb33d2039c4e", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/91/e9/2fc1d723e470d368a4160ed03f67", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/67/2c/ed2086d173cc6e75bd0df57f430c", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/c7/d0/2ed1069a23bc3f2e044e0eb6d493", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/4f/57/5965c82b8374280182436f235aac", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/97/ca/30e53a2369274ab60e4f9f764476", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/b7/16/5bac6aacbe4f663a2ff842338eab", "src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/52/c6/c11130af7b10d6c0321add5518fa", "src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/38/c3/1dedd5e74f2508efc5974c8815a1", "src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/75/9f/bcf597b362c9f2480cb348188bdd", diff --git a/CHANGELOG.md b/CHANGELOG.md index d5c2bcf1..3d03a923 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.20 (build 21075, api 8, 2023-06-08) +### 1.7.20 (build 21077, api 8, 2023-06-08) - 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 @@ -305,6 +305,10 @@ traces are not available. - (build 21074) Added `babase.native_stack_trace()` to fetch native stack traces as strings. +- (build 21076) Hopefully fixed a 'file in use' error for `_appstate_dump_tb` on + windows. Please holler if you are still seeing this. This file gets written + for debugging whenever the logic thread remains unresponsive for several + seconds. ### 1.7.19 (build 20997, api 7, 2023-01-19) diff --git a/Makefile b/Makefile index 9da033be..379472b0 100644 --- a/Makefile +++ b/Makefile @@ -138,13 +138,13 @@ meta-clean: # (except for a few things such as localconfig.json). clean: $(CHECK_CLEAN_SAFETY) - rm -rf build + rm -rf build # Handle this part ourself; can confuse git. git clean -dfx $(ROOT_CLEAN_IGNORES) # Show what clean would delete without actually deleting it. clean-list: $(CHECK_CLEAN_SAFETY) - @echo Would remove build # We do this ourself; not git. + @echo Would remove build # Handle this part ourself; can confuse git. git clean -dnx $(ROOT_CLEAN_IGNORES) # Build/update dummy python modules. diff --git a/src/assets/ba_data/python/babase/_apputils.py b/src/assets/ba_data/python/babase/_apputils.py index c37e015d..a692584c 100644 --- a/src/assets/ba_data/python/babase/_apputils.py +++ b/src/assets/ba_data/python/babase/_apputils.py @@ -234,7 +234,7 @@ def print_corrupt_file_error() -> None: _babase.apptimer(2.0, _babase.getsimplesound('error').play) -_tbfiles: list[TextIO] = [] +_tb_held_files: list[TextIO] = [] @ioprepped @@ -298,11 +298,12 @@ def dump_app_state( os.path.dirname(_babase.app.config_file_path), '_appstate_dump_tb' ) + tbfile = open(tbpath, 'w', encoding='utf-8') + # faulthandler needs the raw file descriptor to still be valid when # it fires, so stuff this into a global var to make sure it doesn't get # cleaned up. - tbfile = open(tbpath, 'w', encoding='utf-8') - _tbfiles.append(tbfile) + _tb_held_files.append(tbfile) if delay > 0.0: faulthandler.dump_traceback_later(delay, file=tbfile) @@ -329,6 +330,14 @@ def log_dumped_app_state() -> None: os.path.dirname(_babase.app.config_file_path), '_appstate_dump_md' ) if os.path.exists(mdpath): + # We may be hanging on to open file descriptors for use by + # faulthandler (see above). If we are, we need to clear them + # now or else we'll get 'file in use' errors below when we + # try to unlink it on windows. + for heldfile in _tb_held_files: + heldfile.close() + _tb_held_files.clear() + with open(mdpath, 'r', encoding='utf-8') as infile: metadata = dataclass_from_json( DumpedAppStateMetadata, infile.read() diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index bd103bf5..f335fcdb 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -28,7 +28,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21075 +TARGET_BALLISTICA_BUILD = 21077 TARGET_BALLISTICA_VERSION = '1.7.20' _g_env_config: EnvConfig | None = None diff --git a/src/ballistica/core/platform/windows/core_platform_windows.cc b/src/ballistica/core/platform/windows/core_platform_windows.cc index 0587b49d..772fe8fc 100644 --- a/src/ballistica/core/platform/windows/core_platform_windows.cc +++ b/src/ballistica/core/platform/windows/core_platform_windows.cc @@ -14,6 +14,8 @@ /* clang-format off */ // Builds fail if this is further up. +// This define gives us the unicode version. +#define DBGHELP_TRANSLATE_TCHAR #include /* clang-format on */ @@ -119,22 +121,24 @@ auto CorePlatformWindows::FormatWinStackTraceForDisplay( SymFromAddr(win_sym_process_, address, NULL, symbol); if (SymGetLineFromAddr64(win_sym_process_, address, &displacement, &line)) { - const char* filename = line.FileName; + std::string filename_s = UTF8Encode(std::wstring(line.FileName)); + const char* filename = filename_s.c_str(); if (!build_src_dir.empty() && !strncmp(filename, build_src_dir.c_str(), build_src_dir.size())) { filename += build_src_dir.size(); } snprintf(linebuf, sizeof(linebuf), - "%-3d %s in %s: line: %lu: address: 0x%p\n", i, symbol->Name, - filename, line.LineNumber, - reinterpret_cast(symbol->Address)); + "%-3d %s in %s: line: %lu: address: 0x%p\n", i, + UTF8Encode(std::wstring(symbol->Name)).c_str(), filename, + line.LineNumber, reinterpret_cast(symbol->Address)); } else { snprintf(linebuf, sizeof(linebuf), "SymGetLineFromAddr64 returned error code %lu.\n", GetLastError()); snprintf(linebuf, sizeof(linebuf), "%-3d %s, address 0x%p.\n", i, - symbol->Name, reinterpret_cast(symbol->Address)); + UTF8Encode(std::wstring(symbol->Name)).c_str(), + reinterpret_cast(symbol->Address)); } out += linebuf; } diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index e7877cc5..a9918efa 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 = 21075; +const int kEngineBuildNumber = 21077; const char* kEngineVersion = "1.7.20"; auto MonolithicMain(const core::CoreConfig& core_config) -> int { From f3158dda8692c5ab3275e32fb196be9653ca86f9 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 8 Jun 2023 17:45:51 -0700 Subject: [PATCH 6/7] fixing windows stack trace bugs --- .efrocachemap | 40 ++++---- CHANGELOG.md | 2 +- src/assets/ba_data/python/baenv.py | 2 +- .../platform/windows/core_platform_windows.cc | 97 +++++++------------ src/ballistica/shared/ballistica.cc | 2 +- 5 files changed, 60 insertions(+), 83 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index c2b9c92d..9389a2aa 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/2a/bf/5ec0907b7ea2ae9ce556bfbaa977", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/b6/90/05fcb5913ac0efa57a0fe9cdb24e", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d5/9c/a39c893eb6f006a229ae677d7d1f", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/4d/bc/a448dcc9cf0de969e9ab1d723b72", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/89/6b/3661b8151586a16adb80a52c293f", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/be/7d/333edec3e78c3b0f06c7a29571d1", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/06/da/1bd3481ad7c525f537f963352131", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b8/9a/ad6ecd60091315a0aa31ca55f736", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/3a/73/6cfd57cf5a424767fd7adcf0a2db", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/53/6f/30d29940df133fa78db5b7c3298c", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/b8/7c/41db8ce4cfece1553f07b891ab34", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/73/cb/2a8b7d0a208147be97198cf3a59c", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/97/56/3af6d1fb98c1e9a637f803c45aa5", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/4f/26/74f101b0d6f038070a025dfb8c0c", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a8/12/1e10c0eb9b55408e6e4d3041cbf4", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/eb/5f/50df0e0f91b1c6fe76de7c7fd048", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/85/3f/dc233392f6d02a62dcad599d264d", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/23/2e/78b07a81552a79d67631075f2632", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/26/0e/1900fb42f7080dd62e35607d6d6d", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/c9/28/c98b86c13cfabd168d8683744cf5", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/4b/7b/656bbbcb41f7b43eeee0d0775d9a", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/f4/3e/b48cab42185c07ff6bfc355f3e5e", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d6/9e/c544d5d86c20a42bcee9f7be1cde", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d1/f1/24aaba8bd77035b9d8601eaea3cb", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/39/1f/6a762fd0ccc4ca62a2b7a51f6cc4", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/1a/5e/3b08dab2bffd74edbe744d3717a3", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c2/4f/f146682e88224ba08219b0ebadc4", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c2/8b/351d1a6de44b45c06e85b39198a1", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/c4/55/0328e26e65974ee613eb0ff8a99e", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/fc/4e/3ff90a44e988e3db7ea66ca4f073", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/4c/b8/5d909139a0fad91c70c6f870feae", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/16/30/16502e5f928405c6d44c0f1a24bd", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/71/bc/546d02a06b6939c3112e155db26c", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/ea/86/eb5c10d57047ee32a82ac3c3790a", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/50/9a/4eef71525e706d4a971c3214422b", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/40/ee/9e6425089e61ff8027871016eeb4", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/7a/b2/d19573e4357cdf109b4e2af43118", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/42/a3/d08f3b7a1594bb1ba4f2ef60dc6e", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/25/45/82f2db0fef5a8df7cb5e71ba4d4c", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/81/14/0121acd7c0cfc62d9c4b51ce60bb", "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/58/55/b6ae6dd4f3615fa87bb170a43233", "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/b9/f8/37285d0ced7794a82534d13c33ac", "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/c7/cc/0c5f0afbfa0ddabaea8d5838562a", diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d03a923..f26bfc47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.20 (build 21077, api 8, 2023-06-08) +### 1.7.20 (build 21078, api 8, 2023-06-08) - 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/baenv.py b/src/assets/ba_data/python/baenv.py index f335fcdb..1696032d 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -28,7 +28,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21077 +TARGET_BALLISTICA_BUILD = 21078 TARGET_BALLISTICA_VERSION = '1.7.20' _g_env_config: EnvConfig | None = None diff --git a/src/ballistica/core/platform/windows/core_platform_windows.cc b/src/ballistica/core/platform/windows/core_platform_windows.cc index 772fe8fc..f7e08276 100644 --- a/src/ballistica/core/platform/windows/core_platform_windows.cc +++ b/src/ballistica/core/platform/windows/core_platform_windows.cc @@ -40,6 +40,7 @@ #endif #include "ballistica/shared/foundation/event_loop.h" +#include "ballistica/shared/generic/utils.h" #include "ballistica/shared/networking/networking_sys.h" #if !defined(UNICODE) || !defined(_UNICODE) @@ -109,7 +110,8 @@ auto CorePlatformWindows::FormatWinStackTraceForDisplay( SYMBOL_INFO* symbol = reinterpret_cast(buf); symbol->MaxNameLen = kTraceMaxFunctionNameLength; symbol->SizeOfStruct = sizeof(SYMBOL_INFO); - DWORD displacement; + DWORD64 s_displacement; + DWORD l_displacement; IMAGEHLP_LINE64 line; line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); @@ -118,27 +120,46 @@ auto CorePlatformWindows::FormatWinStackTraceForDisplay( char linebuf[kTraceMaxFunctionNameLength + 128]; for (int i = 0; i < stack_trace->number_of_frames(); i++) { DWORD64 address = (DWORD64)(stack_trace->stack()[i]); - SymFromAddr(win_sym_process_, address, NULL, symbol); - if (SymGetLineFromAddr64(win_sym_process_, address, &displacement, + std::string symbol_name_s; + if (SymFromAddr(win_sym_process_, address, &s_displacement, symbol)) { + symbol_name_s = UTF8Encode(symbol->Name); + if (!Utils::IsValidUTF8(symbol_name_s)) { + // Debugging some wonky utf8 I was seeing come through. + symbol_name_s = "(got invalid utf8 for symbol name)"; + } + } else { + symbol_name_s = "(unknown symbol name)"; + } + const char* symbol_name = symbol_name_s.c_str(); + + if (SymGetLineFromAddr64(win_sym_process_, address, &l_displacement, &line)) { - std::string filename_s = UTF8Encode(std::wstring(line.FileName)); + std::string filename_s = UTF8Encode(line.FileName); + + if (!Utils::IsValidUTF8(filename_s)) { + // Debugging some wonky utf8 I was seeing come through. + filename_s = "(got invalid utf8 for filename)"; + } const char* filename = filename_s.c_str(); + + // If our filename starts with build_src_dir, trim that part + // off to make things nice and pretty. if (!build_src_dir.empty() && !strncmp(filename, build_src_dir.c_str(), build_src_dir.size())) { filename += build_src_dir.size(); } + snprintf(linebuf, sizeof(linebuf), - "%-3d %s in %s: line: %lu: address: 0x%p\n", i, - UTF8Encode(std::wstring(symbol->Name)).c_str(), filename, - line.LineNumber, reinterpret_cast(symbol->Address)); + "%-3d %s in %s: line: %lu: address: 0x%p\n", i, symbol_name, + filename, line.LineNumber, + reinterpret_cast(symbol->Address)); } else { snprintf(linebuf, sizeof(linebuf), "SymGetLineFromAddr64 returned error code %lu.\n", GetLastError()); snprintf(linebuf, sizeof(linebuf), "%-3d %s, address 0x%p.\n", i, - UTF8Encode(std::wstring(symbol->Name)).c_str(), - reinterpret_cast(symbol->Address)); + symbol_name, reinterpret_cast(symbol->Address)); } out += linebuf; } @@ -174,54 +195,10 @@ auto CorePlatformWindows::UTF8Decode(const std::string& str) -> std::wstring { return wstr; } -#define TRACE_MAX_STACK_FRAMES 256 -#define TRACE_MAX_FUNCTION_NAME_LENGTH 1024 - -// int printStackTrace() { -// void* stack[TRACE_MAX_STACK_FRAMES]; -// if (!win_sym_inited_) { -// win_sym_process_ = GetCurrentProcess(); -// SymInitialize(win_sym_process_, NULL, TRUE); -// win_sym_inited_ = true; -// } -// WORD numberOfFrames = -// CaptureStackBackTrace(0, TRACE_MAX_STACK_FRAMES, stack, NULL); - -// char buf[sizeof(SYMBOL_INFO) -// + (TRACE_MAX_FUNCTION_NAME_LENGTH - 1) * sizeof(TCHAR)]; -// SYMBOL_INFO* symbol = (SYMBOL_INFO*)buf; -// symbol->MaxNameLen = TRACE_MAX_FUNCTION_NAME_LENGTH; -// symbol->SizeOfStruct = sizeof(SYMBOL_INFO); -// DWORD displacement; -// IMAGEHLP_LINE64 line; -// line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); -// for (int i = 0; i < numberOfFrames; i++) { -// DWORD64 address = (DWORD64)(stack[i]); -// SymFromAddr(win_sym_process_, address, NULL, symbol); -// if (SymGetLineFromAddr64(win_sym_process_, address, &displacement, -// &line)) { -// printf("\tat %s in %s: line: %lu: address: 0x%0X\n", symbol->Name, -// line.FileName, line.LineNumber, symbol->Address); -// } else { -// printf("\tSymGetLineFromAddr64 returned error code %lu.\n", -// GetLastError()); -// printf("\tat %s, address 0x%0X.\n", symbol->Name, symbol->Address); -// } -// } -// return 0; -// } - CorePlatformWindows::CorePlatformWindows() { // We should be built in unicode mode. assert(sizeof(TCHAR) == 2); - // printStackTrace(); - - // auto* testtrace = new WinStackTrace(this); - // printf("WINTRACE:\n%s", testtrace->FormatForDisplay().c_str()); - // printf("WOOHOO!\n"); - // fflush(stdout); - // Need to init winsock immediately since we use it for // threading/logging/etc. { @@ -306,7 +283,7 @@ auto CorePlatformWindows::DoGetConfigDirectoryMonolithicDefault() if (result != S_OK) { throw Exception("Unable to get user local-app-data dir."); } - std::string configdir = UTF8Encode(std::wstring(path)) + "\\BallisticaKit"; + std::string configdir = UTF8Encode(path) + "\\BallisticaKit"; return configdir; } @@ -389,7 +366,7 @@ auto CorePlatformWindows::DoAbsPath(const std::string& path, // Buffer not big enough. Should handle this case. return false; } - *outpath = UTF8Encode(std::wstring(abspath)); + *outpath = UTF8Encode(abspath); return true; } @@ -840,7 +817,7 @@ std::string CorePlatformWindows::DoGetDeviceName() { if (result == 0) { device_name = "BallisticaKit Game"; } else { - device_name = UTF8Encode(std::wstring(computer_name)); + device_name = UTF8Encode(computer_name); if (device_name.size() == 0) { device_name = "BallisticaKit Game"; } @@ -876,7 +853,7 @@ auto CorePlatformWindows::DoGetDataDirectoryMonolithicDefault() -> std::string { // If the app path happens to be the current dir, return // the default of "." which gives us cleaner looking paths in // stack traces/etc. - auto out = UTF8Encode(std::wstring(sz_file_name)); + auto out = UTF8Encode(sz_file_name); if (out == GetCWD()) { return CorePlatform::DoGetDataDirectoryMonolithicDefault(); } @@ -905,7 +882,7 @@ auto CorePlatformWindows::GetEnv(const std::string& name) // If it was found and fits in our small static buffer, we're done. if (result <= kStaticBufferSize) { - return UTF8Encode(std::wstring(buffer)); + return UTF8Encode(buffer); } // Ok; apparently its big. Allocate a buffer big enough to hold it and try @@ -920,7 +897,7 @@ auto CorePlatformWindows::GetEnv(const std::string& name) Log(LogLevel::kError, "GetEnv to allocated buffer failed; unexpected."); return {}; } - return UTF8Encode(std::wstring(big_buffer.data())); + return UTF8Encode(big_buffer.data()); } void CorePlatformWindows::SetEnv(const std::string& name, @@ -965,7 +942,7 @@ std::string CorePlatformWindows::GetCWD() { if (result == nullptr) { throw Exception("Error getting CWD; errno=" + std::to_string(errno)); } - return UTF8Encode(std::wstring(buffer)); + return UTF8Encode(buffer); } void CorePlatformWindows::OpenFileExternally(const std::string& path) { diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index a9918efa..f532b334 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 = 21077; +const int kEngineBuildNumber = 21078; const char* kEngineVersion = "1.7.20"; auto MonolithicMain(const core::CoreConfig& core_config) -> int { From 68ccc3df883f3dc6c86dff7947f818b83d4cca23 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 8 Jun 2023 21:25:16 -0700 Subject: [PATCH 7/7] got user sys script dirs working again --- .efrocachemap | 56 +++++++++---------- CHANGELOG.md | 6 +- src/assets/.asset_manifest_public.json | 4 +- src/assets/Makefile | 4 +- src/assets/ba_data/python/babase/_app.py | 3 + src/assets/ba_data/python/babase/_env.py | 17 +++++- .../python/{bauiv1 => babase}/modutils.py | 11 ++-- .../ba_data/python/baclassic/_benchmark.py | 2 +- src/assets/ba_data/python/baenv.py | 27 +++++++-- .../python/bauiv1lib/settings/advanced.py | 4 +- .../base/python/methods/python_methods_app.cc | 4 ++ .../python/methods/python_methods_misc.cc | 29 ++++++++++ src/ballistica/core/platform/core_platform.cc | 34 +++-------- src/ballistica/core/platform/core_platform.h | 2 +- src/ballistica/shared/ballistica.cc | 2 +- .../python/methods/python_methods_ui_v1.cc | 29 ---------- 16 files changed, 129 insertions(+), 105 deletions(-) rename src/assets/ba_data/python/{bauiv1 => babase}/modutils.py (95%) diff --git a/.efrocachemap b/.efrocachemap index 9389a2aa..8ef58a3e 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/4b/7b/656bbbcb41f7b43eeee0d0775d9a", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/f4/3e/b48cab42185c07ff6bfc355f3e5e", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d6/9e/c544d5d86c20a42bcee9f7be1cde", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/d1/f1/24aaba8bd77035b9d8601eaea3cb", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/39/1f/6a762fd0ccc4ca62a2b7a51f6cc4", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/1a/5e/3b08dab2bffd74edbe744d3717a3", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c2/4f/f146682e88224ba08219b0ebadc4", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/c2/8b/351d1a6de44b45c06e85b39198a1", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/c4/55/0328e26e65974ee613eb0ff8a99e", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/fc/4e/3ff90a44e988e3db7ea66ca4f073", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/4c/b8/5d909139a0fad91c70c6f870feae", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/16/30/16502e5f928405c6d44c0f1a24bd", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/71/bc/546d02a06b6939c3112e155db26c", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/ea/86/eb5c10d57047ee32a82ac3c3790a", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/50/9a/4eef71525e706d4a971c3214422b", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/40/ee/9e6425089e61ff8027871016eeb4", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/7a/b2/d19573e4357cdf109b4e2af43118", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/42/a3/d08f3b7a1594bb1ba4f2ef60dc6e", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/25/45/82f2db0fef5a8df7cb5e71ba4d4c", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/81/14/0121acd7c0cfc62d9c4b51ce60bb", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/2f/be/56cbff27830a18d6d60ef31c1cdd", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/f9/e1/344297c240047057658d77dab2c3", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/df/1e/0e166ac6bde0400abf6cf238d4f5", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/cd/5f/62fa669b1054034a39d501ddc8f3", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/a0/c6/17efa1b0fa2d708d6875a57e7d48", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/ef/ea/806a19fe00441dc382954a3f3080", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/93/6e/22f7fc9f33056a672f58bfbe8402", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/40/e8/03cace193459c0635f1342b28b53", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/5a/17/125467b6c2b884e96a5f255466a6", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/23/af/cd64e4cdd02aed0f7c55167fb994", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/11/bc/b5de2f3ea4f68f420efd8e2f8672", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/8e/b1/7e170050323d9e08a5387fb61728", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "https://files.ballistica.net/cache/ba1/12/89/996eb56a1eac10bc5eef98ceb307", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "https://files.ballistica.net/cache/ba1/4f/61/3ea177ccbfca5b78faacd6106324", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/a0/e8/ec660025b4b61eb3f105fbe3915a", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "https://files.ballistica.net/cache/ba1/87/9e/f60d6c7c8097e91f1b75432a96fd", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/80/59/9f5d6da1bfc7e8502ff8faf98371", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "https://files.ballistica.net/cache/ba1/87/3e/b431a2c8ff6a6ab647772c2874d8", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/1c/09/b6bcc16ecdd3b3bde138a7975f84", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "https://files.ballistica.net/cache/ba1/3c/9e/aae04414e59968b1200e45dc490a", "build/prefab/lib/linux_arm64_gui/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/58/55/b6ae6dd4f3615fa87bb170a43233", "build/prefab/lib/linux_arm64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/b9/f8/37285d0ced7794a82534d13c33ac", "build/prefab/lib/linux_arm64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/c7/cc/0c5f0afbfa0ddabaea8d5838562a", @@ -4108,14 +4108,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/96/2e/1b0ba43fe24fe9cc223a434db647", "build/prefab/lib/mac_x86_64_server/debug/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/f3/83/581b7df96f6516032a0747b83e15", "build/prefab/lib/mac_x86_64_server/release/libballistica_plus.a": "https://files.ballistica.net/cache/ba1/6a/6d/7aaf7617929eeff41bc5a574e6c8", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/4c/5b/e6f257859efef56c7bf8a16efb8c", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/be/ac/470e69d1b87eb9a6bb33d2039c4e", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/91/e9/2fc1d723e470d368a4160ed03f67", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/67/2c/ed2086d173cc6e75bd0df57f430c", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/c7/d0/2ed1069a23bc3f2e044e0eb6d493", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/4f/57/5965c82b8374280182436f235aac", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/97/ca/30e53a2369274ab60e4f9f764476", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/b7/16/5bac6aacbe4f663a2ff842338eab", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/cd/49/d11935a48d1d6e2847ab6a51b4fa", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/a1/8a/3b50352ea71fa172f5e32fb60005", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/f0/3c/9e1731eaebd85e6b70ac00113f0a", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/6d/5e/4fa8e18fb7a5e1d41e214a354081", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "https://files.ballistica.net/cache/ba1/25/21/98f151d2018cb4394cf1b533afd8", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "https://files.ballistica.net/cache/ba1/23/53/214f66c1cb5aeace50a7ecc94572", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "https://files.ballistica.net/cache/ba1/92/54/9be16e024bf4a6bc1015c487402c", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "https://files.ballistica.net/cache/ba1/42/ae/47ec74d1efe9b02bf7fc88a310fb", "src/assets/ba_data/python/babase/_mgen/__init__.py": "https://files.ballistica.net/cache/ba1/52/c6/c11130af7b10d6c0321add5518fa", "src/assets/ba_data/python/babase/_mgen/enums.py": "https://files.ballistica.net/cache/ba1/38/c3/1dedd5e74f2508efc5974c8815a1", "src/ballistica/base/mgen/pyembed/binding_base.inc": "https://files.ballistica.net/cache/ba1/75/9f/bcf597b362c9f2480cb348188bdd", diff --git a/CHANGELOG.md b/CHANGELOG.md index f26bfc47..1f6d2126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.20 (build 21078, api 8, 2023-06-08) +### 1.7.20 (build 21079, api 8, 2023-06-08) - 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 @@ -309,6 +309,10 @@ windows. Please holler if you are still seeing this. This file gets written for debugging whenever the logic thread remains unresponsive for several seconds. +- (build 21078) Custom system scripts dirs works again (complete copies of app + system scripts living in your mods directory under `sys/$(YOUR_APP_VERSION)`. + Tools for creating/destroying these setups are now at `babase.modutils` (they + had been placed under bauiv1 but that was just silly). ### 1.7.19 (build 20997, api 7, 2023-01-19) diff --git a/src/assets/.asset_manifest_public.json b/src/assets/.asset_manifest_public.json index e1420658..8cb58fba 100644 --- a/src/assets/.asset_manifest_public.json +++ b/src/assets/.asset_manifest_public.json @@ -28,6 +28,7 @@ "ba_data/python/babase/__pycache__/_text.cpython-311.opt-1.pyc", "ba_data/python/babase/__pycache__/_workspace.cpython-311.opt-1.pyc", "ba_data/python/babase/__pycache__/internal.cpython-311.opt-1.pyc", + "ba_data/python/babase/__pycache__/modutils.cpython-311.opt-1.pyc", "ba_data/python/babase/_accountv2.py", "ba_data/python/babase/_app.py", "ba_data/python/babase/_appcomponent.py", @@ -58,6 +59,7 @@ "ba_data/python/babase/_text.py", "ba_data/python/babase/_workspace.py", "ba_data/python/babase/internal.py", + "ba_data/python/babase/modutils.py", "ba_data/python/baclassic/__init__.py", "ba_data/python/baclassic/__pycache__/__init__.cpython-311.opt-1.pyc", "ba_data/python/baclassic/__pycache__/_accountv1.cpython-311.opt-1.pyc", @@ -346,10 +348,8 @@ "ba_data/python/bauiv1/__init__.py", "ba_data/python/bauiv1/__pycache__/__init__.cpython-311.opt-1.pyc", "ba_data/python/bauiv1/__pycache__/_hooks.cpython-311.opt-1.pyc", - "ba_data/python/bauiv1/__pycache__/modutils.cpython-311.opt-1.pyc", "ba_data/python/bauiv1/__pycache__/onscreenkeyboard.cpython-311.opt-1.pyc", "ba_data/python/bauiv1/_hooks.py", - "ba_data/python/bauiv1/modutils.py", "ba_data/python/bauiv1/onscreenkeyboard.py", "ba_data/python/bauiv1/ui/__init__.py", "ba_data/python/bauiv1/ui/__pycache__/__init__.cpython-311.opt-1.pyc", diff --git a/src/assets/Makefile b/src/assets/Makefile index 439718ea..8b389157 100644 --- a/src/assets/Makefile +++ b/src/assets/Makefile @@ -174,6 +174,7 @@ SCRIPT_TARGETS_PY_PUBLIC = \ $(BUILD_DIR)/ba_data/python/babase/_text.py \ $(BUILD_DIR)/ba_data/python/babase/_workspace.py \ $(BUILD_DIR)/ba_data/python/babase/internal.py \ + $(BUILD_DIR)/ba_data/python/babase/modutils.py \ $(BUILD_DIR)/ba_data/python/baclassic/__init__.py \ $(BUILD_DIR)/ba_data/python/baclassic/_accountv1.py \ $(BUILD_DIR)/ba_data/python/baclassic/_achievement.py \ @@ -310,7 +311,6 @@ SCRIPT_TARGETS_PY_PUBLIC = \ $(BUILD_DIR)/ba_data/python/batemplatefs/_subsystem.py \ $(BUILD_DIR)/ba_data/python/bauiv1/__init__.py \ $(BUILD_DIR)/ba_data/python/bauiv1/_hooks.py \ - $(BUILD_DIR)/ba_data/python/bauiv1/modutils.py \ $(BUILD_DIR)/ba_data/python/bauiv1/onscreenkeyboard.py \ $(BUILD_DIR)/ba_data/python/bauiv1/ui/__init__.py \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__init__.py \ @@ -446,6 +446,7 @@ SCRIPT_TARGETS_PYC_PUBLIC = \ $(BUILD_DIR)/ba_data/python/babase/__pycache__/_text.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/babase/__pycache__/_workspace.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/babase/__pycache__/internal.cpython-311.opt-1.pyc \ + $(BUILD_DIR)/ba_data/python/babase/__pycache__/modutils.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/baclassic/__pycache__/__init__.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/baclassic/__pycache__/_accountv1.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/baclassic/__pycache__/_achievement.cpython-311.opt-1.pyc \ @@ -582,7 +583,6 @@ SCRIPT_TARGETS_PYC_PUBLIC = \ $(BUILD_DIR)/ba_data/python/batemplatefs/__pycache__/_subsystem.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1/__pycache__/__init__.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1/__pycache__/_hooks.cpython-311.opt-1.pyc \ - $(BUILD_DIR)/ba_data/python/bauiv1/__pycache__/modutils.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1/__pycache__/onscreenkeyboard.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1/ui/__pycache__/__init__.cpython-311.opt-1.pyc \ $(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/__init__.cpython-311.opt-1.pyc \ diff --git a/src/assets/ba_data/python/babase/_app.py b/src/assets/ba_data/python/babase/_app.py index 12b17c34..239a5611 100644 --- a/src/assets/ba_data/python/babase/_app.py +++ b/src/assets/ba_data/python/babase/_app.py @@ -482,9 +482,12 @@ class App: from babase import _asyncio from babase import _appconfig from babase._apputils import log_dumped_app_state, AppHealthMonitor + import babase._env assert _babase.in_logic_thread() + babase._env.on_app_launching() + self._aioloop = _asyncio.setup_asyncio() self.health_monitor = AppHealthMonitor() diff --git a/src/assets/ba_data/python/babase/_env.py b/src/assets/ba_data/python/babase/_env.py index 02c225e7..a651dc88 100644 --- a/src/assets/ba_data/python/babase/_env.py +++ b/src/assets/ba_data/python/babase/_env.py @@ -64,8 +64,8 @@ def on_native_module_import() -> None: def setup_env_for_app_run() -> None: """Set stuff such as interrupt handlers for a run of the app.""" import gc - import _babase import baenv + import _babase global _g_babase_app_started # pylint: disable=global-statement @@ -136,6 +136,21 @@ def setup_env_for_app_run() -> None: asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) +def on_app_launching() -> None: + """Called when the app reaches the launching state.""" + import _babase + import baenv + + assert _babase.in_logic_thread() + + # Let the user know if the app python dir is a custom one. + if baenv.g_user_system_scripts_dir is not None: + _babase.screenmessage( + f"Using user system scripts: '{baenv.g_user_system_scripts_dir}'", + color=(0.6, 0.6, 1.0), + ) + + def _feed_logs_to_babase(log_handler: LogHandler) -> None: """Route log/print output to internal ballistica console/etc.""" import _babase diff --git a/src/assets/ba_data/python/bauiv1/modutils.py b/src/assets/ba_data/python/babase/modutils.py similarity index 95% rename from src/assets/ba_data/python/bauiv1/modutils.py rename to src/assets/ba_data/python/babase/modutils.py index b89725b3..2c5d5335 100644 --- a/src/assets/ba_data/python/bauiv1/modutils.py +++ b/src/assets/ba_data/python/babase/modutils.py @@ -7,7 +7,6 @@ from typing import TYPE_CHECKING import os import _babase -import _bauiv1 if TYPE_CHECKING: from typing import Sequence @@ -50,7 +49,7 @@ def _request_storage_permission() -> bool: from babase._mgen.enums import Permission if not _babase.have_permission(Permission.STORAGE): - _bauiv1.getsound('error').play() + _babase.getsimplesound('error').play() _babase.screenmessage( Lstr(resource='storagePermissionAccessText'), color=(1, 0, 0) ) @@ -103,7 +102,7 @@ def show_user_scripts() -> None: # On a few platforms we try to open the dir in the UI. if app.classic is not None and app.classic.platform in ['mac', 'windows']: - _bauiv1.open_dir_externally(app.python_directory_user) + _babase.open_dir_externally(app.python_directory_user) # Otherwise we just print a pretty version of it. else: @@ -111,9 +110,9 @@ def show_user_scripts() -> None: def create_user_system_scripts() -> None: - """Set up a copy of Ballistica system scripts under your user scripts dir. + """Set up a copy of Ballistica app scripts under user scripts dir. - (for editing and experiment with) + (for editing and experimenting) """ import shutil @@ -180,7 +179,7 @@ def delete_user_system_scripts() -> None: f' scripts. (use babase.quit() to exit the game)' ) else: - print('User system scripts not found.') + print(f"User system scripts not found at '{path}'.") # If the sys path is empty, kill it. dpath = app.python_directory_user + '/sys' diff --git a/src/assets/ba_data/python/baclassic/_benchmark.py b/src/assets/ba_data/python/baclassic/_benchmark.py index 3ed6532e..5b36006c 100644 --- a/src/assets/ba_data/python/baclassic/_benchmark.py +++ b/src/assets/ba_data/python/baclassic/_benchmark.py @@ -59,7 +59,7 @@ def run_stress_test( round_duration: int = 30, ) -> None: """Run a stress test.""" - from bauiv1 import modutils + from babase import modutils from babase._general import Call _babase.screenmessage( diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index 1696032d..53bee0d5 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -28,11 +28,12 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21078 +TARGET_BALLISTICA_BUILD = 21079 TARGET_BALLISTICA_VERSION = '1.7.20' _g_env_config: EnvConfig | None = None g_paths_set_failed = False # pylint: disable=invalid-name +g_user_system_scripts_dir: str | None = None # pylint: disable=invalid-name @dataclass @@ -43,6 +44,7 @@ class EnvConfig: data_dir: str user_python_dir: str | None app_python_dir: str | None + standard_app_python_dir: str site_python_dir: str | None log_handler: LogHandler | None @@ -76,6 +78,7 @@ def configure( affecting where those modules get loaded from. """ # pylint: disable=too-many-branches + # pylint: disable=too-many-locals global _g_env_config # pylint: disable=global-statement if _g_env_config is not None: @@ -125,6 +128,10 @@ def configure( # Ok now Python paths. + # By default, app-python-dir is simply ba_data/python under + # data-dir. + standard_app_python_dir = str(Path(data_dir, 'ba_data', 'python')) + # If _babase has already been imported, there's not much we can do # at this point aside from complain and inform for next time. if '_babase' in sys.modules: @@ -141,10 +148,8 @@ def configure( # Ok; _babase hasn't been imported yet so we can muck with # Python paths. - # By default, app-python-dir is simply ba_data/python under - # data-dir. if app_python_dir is None: - app_python_dir = str(Path(data_dir, 'ba_data', 'python')) + app_python_dir = standard_app_python_dir # Likewise site-python-dir defaults to ba_data/python-site-packages. if site_python_dir is None: @@ -156,7 +161,18 @@ def configure( if user_python_dir is None: user_python_dir = str(Path(config_dir, 'mods')) - # Ok, now add these to sys.path. + # Wherever our user_python_dir is, if we find a sys/FOO dir + # under it where FOO matches our version, use that as our + # app_python_dir. + check_dir = os.path.join( + user_python_dir, 'sys', TARGET_BALLISTICA_VERSION + ) + if os.path.isdir(check_dir): + global g_user_system_scripts_dir # pylint: disable=global-statement + g_user_system_scripts_dir = check_dir + app_python_dir = check_dir + + # Ok, now apply these to sys.path. # First off, strip out any instances of the path containing this # module. We will probably be re-adding the same path in a @@ -194,6 +210,7 @@ def configure( data_dir=data_dir, user_python_dir=user_python_dir, app_python_dir=app_python_dir, + standard_app_python_dir=standard_app_python_dir, site_python_dir=site_python_dir, log_handler=log_handler, ) diff --git a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py index 38e58c2e..1b3c96d3 100644 --- a/src/assets/ba_data/python/bauiv1lib/settings/advanced.py +++ b/src/assets/ba_data/python/bauiv1lib/settings/advanced.py @@ -188,7 +188,7 @@ class AdvancedSettingsWindow(bui.Window): @staticmethod def _preload_modules() -> None: """Preload modules we use (called in bg thread).""" - from bauiv1 import modutils as _unused2 + from babase import modutils as _unused2 from bauiv1lib import config as _unused1 from bauiv1lib.settings import vrtesting as _unused3 from bauiv1lib.settings import nettesting as _unused4 @@ -235,7 +235,7 @@ class AdvancedSettingsWindow(bui.Window): # pylint: disable=too-many-locals from bauiv1lib.config import ConfigCheckBox - from bauiv1.modutils import show_user_scripts + from babase.modutils import show_user_scripts plus = bui.app.plus assert plus is not None diff --git a/src/ballistica/base/python/methods/python_methods_app.cc b/src/ballistica/base/python/methods/python_methods_app.cc index 2e5d562d..fb4f16dd 100644 --- a/src/ballistica/base/python/methods/python_methods_app.cc +++ b/src/ballistica/base/python/methods/python_methods_app.cc @@ -207,6 +207,10 @@ static auto PyPushCall(PyObject* self, PyObject* args, PyObject* keywds) return nullptr; } + if (!g_base->logic->event_loop()) { + throw Exception("pushcall cannot be used before start-app is called."); + } + // 'raw' mode does no thread checking and no context saves/restores. if (raw) { assert(Python::HaveGIL()); diff --git a/src/ballistica/base/python/methods/python_methods_misc.cc b/src/ballistica/base/python/methods/python_methods_misc.cc index 47e553fa..250408b5 100644 --- a/src/ballistica/base/python/methods/python_methods_misc.cc +++ b/src/ballistica/base/python/methods/python_methods_misc.cc @@ -1414,6 +1414,34 @@ static PyMethodDef PyNativeStackTraceDef = { "Only use them for debugging.", }; +// -------------------------- open_dir_externally ------------------------------ + +static auto PyOpenDirExternally(PyObject* self, PyObject* args, + PyObject* keywds) -> PyObject* { + BA_PYTHON_TRY; + char* path = nullptr; + static const char* kwlist[] = {"path", nullptr}; + if (!PyArg_ParseTupleAndKeywords(args, keywds, "s", + const_cast(kwlist), &path)) { + return nullptr; + } + g_core->platform->OpenDirExternally(path); + Py_RETURN_NONE; + BA_PYTHON_CATCH; +} + +static PyMethodDef PyOpenDirExternallyDef = { + "open_dir_externally", // name + (PyCFunction)PyOpenDirExternally, // method + METH_VARARGS | METH_KEYWORDS, // flags + + "open_dir_externally(path: str) -> None\n" + "\n" + "(internal)\n" + "\n" + "Open the provided dir in the default external app.", +}; + // ----------------------------------------------------------------------------- auto PythonMethodsMisc::GetMethods() -> std::vector { @@ -1468,6 +1496,7 @@ auto PythonMethodsMisc::GetMethods() -> std::vector { PyGetSimpleSoundDef, PyHasTouchScreenDef, PyNativeStackTraceDef, + PyOpenDirExternallyDef, }; } diff --git a/src/ballistica/core/platform/core_platform.cc b/src/ballistica/core/platform/core_platform.cc index f1ff0f34..28c1c0a8 100644 --- a/src/ballistica/core/platform/core_platform.cc +++ b/src/ballistica/core/platform/core_platform.cc @@ -251,32 +251,6 @@ auto CorePlatform::GetDefaultVolatileDataDirectory() -> std::string { auto CorePlatform::GetAppPythonDirectory() -> std::optional { BA_PRECONDITION(have_ba_env_vals_); return ba_env_app_python_dir_; - - // TODO(ericf) - recreate this behavior within baenv. - // // If there is a sys/VERSION in the user-python dir we use that. - // app_python_dir_ = GetUserPythonDirectoryMonolithicDefault() + BA_DIRSLASH - // + "sys" + BA_DIRSLASH + kEngineVersion; - - // // Fall back to our default if that doesn't exist. - // if (FilePathExists(app_python_dir_)) { - // using_custom_app_python_dir_ = true; - // Log(LogLevel::kInfo, - // "Using custom app Python path: '" - // + (GetUserPythonDirectoryMonolithicDefault() + BA_DIRSLASH + - // "sys" - // + BA_DIRSLASH + kEngineVersion) - // + "'."); - - // } else { - // // Special case: if CWD is '.', omit the './' for a prettier path. - // app_python_dir_ = std::string("ba_data") + BA_DIRSLASH + "python"; - // auto data_dir = GetDataDirectoryMonolithicDefault(); - // if (data_dir != ".") { - // app_python_dir_ = data_dir + BA_DIRSLASH + app_python_dir_; - // } - // } - // } - // return app_python_dir_; } auto CorePlatform::GetSitePythonDirectory() -> std::optional { @@ -1250,6 +1224,14 @@ void CorePlatform::SetBaEnvVals(const PythonRef& ref) { ba_env_site_python_dir_ = ref.GetAttr("site_python_dir").ValueAsOptionalString(); + // Consider app-python-dir 'custom' if baenv provided a value + // for it AND that value differs from baenv's default. + auto standard_app_python_dir = + ref.GetAttr("standard_app_python_dir").ValueAsString(); + using_custom_app_python_dir_ = + ba_env_app_python_dir_.has_value() + && *ba_env_app_python_dir_ != standard_app_python_dir; + // Ok, now look for the existence of ba_data in the dir we've got. auto fullpath = ba_env_data_dir_ + BA_DIRSLASH + "ba_data"; if (!FilePathExists(fullpath)) { diff --git a/src/ballistica/core/platform/core_platform.h b/src/ballistica/core/platform/core_platform.h index 24d0fc4a..d9f812cc 100644 --- a/src/ballistica/core/platform/core_platform.h +++ b/src/ballistica/core/platform/core_platform.h @@ -546,7 +546,7 @@ class CorePlatform { private: bool is_stdin_a_terminal_{}; - bool using_custom_app_python_dir_{}; // FIXME not wired up currently. + bool using_custom_app_python_dir_{}; bool have_has_touchscreen_value_{}; bool have_touchscreen_{}; bool is_tegra_k1_{}; diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index f532b334..eaca08e5 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 = 21078; +const int kEngineBuildNumber = 21079; const char* kEngineVersion = "1.7.20"; auto MonolithicMain(const core::CoreConfig& core_config) -> int { diff --git a/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc b/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc index aba4e9c3..f736ac58 100644 --- a/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc +++ b/src/ballistica/ui_v1/python/methods/python_methods_ui_v1.cc @@ -2799,34 +2799,6 @@ static PyMethodDef PyOpenFileExternallyDef = { "Open the provided file in the default external app.", }; -// -------------------------- open_dir_externally ------------------------------ - -static auto PyOpenDirExternally(PyObject* self, PyObject* args, - PyObject* keywds) -> PyObject* { - BA_PYTHON_TRY; - char* path = nullptr; - static const char* kwlist[] = {"path", nullptr}; - if (!PyArg_ParseTupleAndKeywords(args, keywds, "s", - const_cast(kwlist), &path)) { - return nullptr; - } - g_core->platform->OpenDirExternally(path); - Py_RETURN_NONE; - BA_PYTHON_CATCH; -} - -static PyMethodDef PyOpenDirExternallyDef = { - "open_dir_externally", // name - (PyCFunction)PyOpenDirExternally, // method - METH_VARARGS | METH_KEYWORDS, // flags - - "open_dir_externally(path: str) -> None\n" - "\n" - "(internal)\n" - "\n" - "Open the provided dir in the default external app.", -}; - // ----------------------------- console_print --------------------------------- static auto PyConsolePrint(PyObject* self, PyObject* args) -> PyObject* { @@ -2899,7 +2871,6 @@ auto PythonMethodsUIV1::GetMethods() -> std::vector { PyGetQRCodeTextureDef, PyIsPartyIconVisibleDef, PyConsolePrintDef, - PyOpenDirExternallyDef, PyOpenFileExternallyDef, PyOpenURLDef, PyBackPressDef,