Repository navigation
BGF: Minor fixits, part 1 - #125
Merged
Merged
Conversation
…base dtor, fix Home keycode typo Small, low-risk fixes in base_game_framework for undefined behavior and compiler warnings: - VulkanAPIUtils::CheckVkResult: pass the missing `message` argument for the `%s` specifier (guarding against nullptr). - GraphicsAPIGLES::ParseEGLConfigs: pass the missing `feature_flags_` argument for the `0x%x` specifier. - DebugManager::Log / PlatformUtilLog::Log: add printf format attributes (via a new BGF_PRINTF_FORMAT macro, a no-op on non-GCC/Clang compilers) so -Wformat actually checks call sites. Previously these wrappers were unannotated, so the compiler could not catch the two bugs above, and -Wformat-nonliteral flagged the forwarding call to __android_log_vprint. - GraphicsAPIBase: add a virtual default destructor so derived GraphicsAPIGLES/GraphicsAPIVulkan objects are destroyed correctly through a base pointer (fixes -Wnon-virtual-dtor). - EventKeyCode: add correctly spelled kKeyCode_Home; keep kKeyCode_Gome as an alias marked [[deprecated]] for source compatibility. Tested: agdktunnel builds with -Wall -Werror. All base_game_framework sources compile cleanly with -Wformat -Werror=format-security -Wformat-nonliteral -Wnon-virtual-dtor -Werror. Reintroducing either original log bug now fails with -Wformat-insufficient-args. Using kKeyCode_Gome emits -Wdeprecated-declarations. Verified agdktunnel launches and renders via Vulkan on a Pixel 10 Pro.
Fix JNI resource leaks and a Java data race in base_game_framework's Android platform utilities: - FilesystemManager / SystemInfoUtils: release the UTF chars obtained with GetStringUTFChars for the root paths and package name, via a new PlatformUtilAndroid::JStringToString() helper. - Util object global ref: BaseGameFramework_Destroy() now deletes the global ref to the BaseGameFrameworkUtils object. Previously it was never deleted, so every Activity recreation leaked the old Activity. registerUtilObject() now passes its owning Activity, kept as a weak global ref. Destroy only releases a registration owned by its own Activity, so it can't free a newer Activity's registration (a new onCreate can run before the old onDestroy). No reflection is used, so this works under R8/ProGuard. - Thread safety: the global ref is only accessed under a mutex. Callers now get their own local ref via NewUtilObjectLocalRef(), which keeps the object valid even if a newer Activity replaces the registration. This removes the cached class ref and jmethodIDs. - Java exceptions: every native -> BaseGameFrameworkUtils call now checks for and clears pending exceptions. GetRootPath() and GetExternalStorageEmulated() null-check getExternalFilesDir() in Java instead of throwing a NullPointerException across JNI. - BaseGameFrameworkUtils.retrieveFreeSpace(): the lock was held only while starting the background thread, not while it wrote the results, racing with GetEstimatedFreeSpace(). The thread now queries into locals and publishes all values under the lock in a finally block, also catching RuntimeException (getUuidForPath() can throw IllegalArgumentException). mFreeSpace is final, which also fixes an NPE if queried before Initialize(). - BaseGameFramework_Destroy() clears the JNIEnv, android_app, activity and native window pointers after detaching, unless a newer instance has already re-initialized them. Tested on a Pixel 10 Pro with agdktunnel and CheckJNI enabled: no CheckJNI errors. Forced 6 Activity recreations (night-mode toggles) and checked a heap dump. Before: 7 BaseGameFrameworkUtils objects pinned by JNI global refs. After: 1 (the current Activity's). After each recreation, a temporary log confirmed root paths, package name, free space, emulated storage, DPI and AEP support were correct. The app renders normally. A new Activity registering before the old one is destroyed was not reproduced on device.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix log format args, enable printf format checking, add virtual base dtor, fix Home keycode typo
Small, low-risk fixes in base_game_framework for undefined behavior and compiler warnings:
messageargument for the%sspecifier (guarding against nullptr).feature_flags_argument for the0x%xspecifier.Tested: agdktunnel builds with -Wall -Werror. All base_game_framework sources compile cleanly with -Wformat -Werror=format-security -Wformat-nonliteral -Wnon-virtual-dtor -Werror. Reintroducing either original log bug now fails with -Wformat-insufficient-args. Using kKeyCode_Gome emits -Wdeprecated-declarations.