-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
[3.2] [iOS] Leaks and deprecations fix #41504
Conversation
Is there any reason to not use Migrating some changes from #40434 as well as #40766 after #41340 gets merged should probably make cherry-picking iOS changes for |
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.
Everything else seems to be fine.
platform/iphone/view_controller.mm
Outdated
p_args[p_argc] = NULL; | ||
[str release]; |
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.
No, this should not be released here, it's intentionally leaked to preserve C-string.
Proper fix should do something like:
- In the
iphone_main
function: save original value ofargc
before callingadd_path
andadd_cmdline
. - In
add_path
andadd_cmdline
: allocate memory and copy C-string (retain
should be removed). - In the
iphone_main
function, afterMain::setup
call: deallocate C-strings starting fromargc
saved in step one.
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.
Should early release
result in crash or leak, which could be traced?
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.
Actually there's no new NSString
created and released here, objectForKey
return existing key of [[NSBundle mainBundle] infoDictionary]
which should be there while app is running, probably it's fine to just remove retain
instead of adding release
and no need to copy C-string.
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.
Updated PR. Also tested it with custom godot_path
and Instruments. Everything seems to be working correctly. Only InAppStore
is reporting a leak at initializer, but I guess it could be fixed after #41340
platform/iphone/view_controller.mm
Outdated
@@ -65,7 +66,8 @@ int add_cmdline(int p_argc, char **p_args) { | |||
if (!str) | |||
continue; | |||
[str retain]; // @todo delete these at some point | |||
p_args[p_argc++] = (char *)[str cString]; | |||
p_args[p_argc++] = (char *)[str cStringUsingEncoding:NSUTF8StringEncoding]; | |||
[str release]; |
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.
Same as above.
d57f9a3
to
fd1b28e
Compare
Fixes some deprecations and leaks reported by Xcode Analyzer
fd1b28e
to
f81c6c5
Compare
@bruvzg what do you think about using |
The only thing using |
Well, mixing ARC and non-ARC code is not really a problem, so I think it could be addressed for both |
Thanks! |
Fixes some iOS warnings as well as leaks that was reported by Xcode Analyzer.
Some parts haven't been changed as they are addressed by other PRs, like #41173 or #41340