-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed #17594: [android] fix crash and memory leaks if launching game multiple times on Android platform with PhysX module enabled. #17602
Conversation
Interface Check ReportThis pull request does not change any public interfaces ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
16 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings
// Move the map to avoid erase operation in the following for loop since 'delete' will trigger ~PhysxSharedBody. | ||
// clearCache is invoked only in the destructor of PhysXWorld. | ||
auto tmpMap = std::move(sharedBodesMap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using a unique_ptr for automatic memory management of PhysXSharedBody instances
@@ -87,6 +87,12 @@ void ADPFManager::initialize() { | |||
} | |||
} | |||
|
|||
void ADPFManager::destroy() { | |||
JNIEnv *env = cc::JniHelper::getEnv(); | |||
env->DeleteGlobalRef(obj_power_service_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider checking if obj_power_service_ is not null before deleting
public static void destroy() { | ||
mDatabaseOpenHelper = null; | ||
if (mDatabase != null) { | ||
mDatabase.close(); | ||
mDatabase = null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider adding a null check before closing mDatabase to prevent potential NullPointerException
public static void resetStaticVariables() { | ||
mSensorHandler = null; | ||
mEnableSensor = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider adding synchronization to prevent potential race conditions when resetting static variables.
if (mVideoHandler != null) { | ||
mVideoHandler.removeCallbacksAndMessages(null); | ||
mVideoHandler = null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using a more specific method like removeCallbacks() instead of removeCallbacksAndMessages(null) if possible
sHandler.removeCallbacksAndMessages(null); | ||
sHandler = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Ensure all callbacks are removed before setting sHandler to null to prevent potential memory leaks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
2622a92
to
04ca338
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
18 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings
// Move the map to avoid erase operation in the following for loop since 'delete' will trigger ~PhysxSharedBody. | ||
// clearCache is invoked only in the destructor of PhysXWorld. | ||
auto tmpMap = std::move(sharedBodesMap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using a unique_ptr for automatic memory management of PhysXSharedBody instances
@@ -87,6 +87,12 @@ void ADPFManager::initialize() { | |||
} | |||
} | |||
|
|||
void ADPFManager::destroy() { | |||
JNIEnv *env = cc::JniHelper::getEnv(); | |||
env->DeleteGlobalRef(obj_power_service_); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider checking if obj_power_service_ is not null before deleting
@@ -53,8 +53,10 @@ public static boolean init(String dbName, String tableName) { | |||
} | |||
|
|||
public static void destroy() { | |||
mDatabaseOpenHelper = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider adding a null check before setting mDatabaseOpenHelper to null
if (mVideoHandler != null) { | ||
mVideoHandler.removeCallbacksAndMessages(null); | ||
mVideoHandler = null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using a more specific method like removeCallbacks() instead of removeCallbacksAndMessages(null) if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
@cocos-robot run test cases |
@dumganhar, Please check the result of
Task Details
|
@dumganhar, Please check the result of
Task Details
|
…game multiple times on Android platform with PhysX module enabled. (cocos#17602)
Re: #17594
cocos/google-game-sdk#9
cocos/cocos-engine-external#458
Changelog
Continuous Integration
This pull request:
Compatibility Check
This pull request:
Greptile Summary
This pull request updates the external dependency version for the engine-native-external repository, addressing crash and memory leak issues on Android platforms with PhysX module enabled.
native/external-config.json
to use engine-native-external version v3.8.5-1, up from v3.8.4-5