Closed alexzheng closed 4 years ago
All these crash issues on iOS 11 prevent the stable 2.1 from be readying for publishing apps.
I think this should be fixed on 2.1 also.
@alexzheng https://stackoverflow.com/questions/45319215/ios-11-beta-4-presentrenderbuffer-crash Does this workaround work for you? I don't have a clue what actual problem is, but I found this issue exists with other engine or framework. https://issuetracker.unity3d.com/issues/ios-opengles-opengles2-and-opengles3-builds-crashes-on-ios11-in-gleshelper-dot-mm http://discuss.cocos2d-x.org/t/3-15-1-crash-in-ios-11-beta-4/38168/9
not work.
Can you show the output of 'bt full'?
nothing more for bt full
(lldb) bt full error: _regexp-bt
Cann't you reproduce it? It crash for each simple demo project on iOS 11 device.
Try this patch, it's not crashing for me anymore with it: iphone_crashfix.patch.zip
Still crash. Am I miss some code?
void AudioDriverIphone::finish() { AURenderCallbackStruct callback; zeromem(&callback, sizeof(AURenderCallbackStruct)); OSStatus result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &callback, sizeof(callback)); if (result != noErr) { ERR_PRINT("AudioUnitSetProperty failed"); }
memdelete_arr(samples_in);
};
void OSIPhone::finalize() {
audio_driver->finish();
if (main_loop) // should not happen?
memdelete(main_loop);
visual_server->finish();
memdelete(visual_server);
memdelete(rasterizer);
physics_server->finish();
memdelete(physics_server);
physics_2d_server->finish();
memdelete(physics_2d_server);
spatial_sound_server->finish();
memdelete(spatial_sound_server);
memdelete(input);
spatial_sound_2d_server->finish();
memdelete(spatial_sound_2d_server);
};
My device is a iPhone 7 plus.
That's weird, code you posted seems fine, did it crash on the same place as before? And can you add a print_line("AudioDriverIphone::finish");
on AudioDriverIphone::finish()
to see if it's getting called.
I tested it on an iPhone 6 with iOS 11.0.1. I don't have a 7 plus one sadly :(.
the same place. output:
iphone_finish AudioDriverIphone::finish [1;33mWARNING: cleanup: [0m[1mObjectDB Instances still exist! [0;33m At: core/object.cpp:1845.[0m [1;31mERROR: free_static: [0m[1mCondition ' !MemoryPoolStatic::get_singleton() ' is true. [0;31m At: core/os/memory.cpp:59.[0m [1;31mERROR: free_static: [0m[1mCondition ' !MemoryPoolStatic::get_singleton() ' is true. [0;31m At: core/os/memory.cpp:59.[0m [1;31mERROR: free_static: [0m[1mCondition ' !MemoryPoolStatic::get_singleton() ' is true. [0;31m At: core/os/memory.cpp:59.[0m (lldb) bt
AudioServerSW::_thread_func(self=0x000000010a278020) at audio_server_sw.cpp:729 frame #1: 0x0000000100ed119c godot_opt.iphone
ThreadPosix::thread_callback(userdata=0x00000001c011ee90) at thread_posix.cpp:58
frame #2: 0x000000018658432c libsystem_pthread.dylib_pthread_body + 308 frame #3: 0x00000001865841f8 libsystem_pthread.dylib
_pthread_start + 312
frame #4: 0x0000000186582c38 libsystem_pthread.dylib`thread_start + 4
(lldb) Seems to be a different crash actually, it's crashing on _thread_func now.
Try this on platform/iphone/os_iphone.cpp
:
diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp
index 10dc296..1754496 100644
--- a/platform/iphone/os_iphone.cpp
+++ b/platform/iphone/os_iphone.cpp
@@ -368,9 +368,14 @@ void OSIPhone::delete_main_loop() {
void OSIPhone::finalize() {
+ audio_driver->finish();
+
if (main_loop) // should not happen?
memdelete(main_loop);
+ audio_server->finish();
+ memdelete(audio_server);
+
visual_server->finish();
memdelete(visual_server);
memdelete(rasterizer);
And this on servers/audio/audio_server_sw.cpp
:
diff --git a/servers/audio/audio_server_sw.cpp b/servers/audio/audio_server_sw.cpp
index 28da2c1..841552d 100644
--- a/servers/audio/audio_server_sw.cpp
+++ b/servers/audio/audio_server_sw.cpp
@@ -726,7 +726,8 @@ void AudioServerSW::_thread_func(void *self) {
while (!as->exit_update_thread) {
as->_update_streams(true);
- OS::get_singleton()->delay_usec(5000);
+ if (OS::get_singleton())
+ OS::get_singleton()->delay_usec(5000);
}
}
this stop the crash,but freezes the app when enter to foreground and then crash
I had the same crash as @alexzheng described in his initial post. However, I think that the problem is not the crash after iphone_finish gets called:
iphone_finish �[1;33mWARNING: cleanup: �[0m�[1mObjectDB Instances still exist! �[0;33m At: core/object.cpp:1845.�[0m �[1;31mERROR: free_static: �[0m�[1mCondition ' !MemoryPoolStatic::get_singleton() ' is true. �[0;31m At: core/os/memory.cpp:59.�[0m �[1;31mERROR: free_static: �[0m�[1mCondition ' !MemoryPoolStatic::get_singleton() ' is true. �[0;31m At: core/os/memory.cpp:59.�[0m �[1;31mERROR: free_static: �[0m�[1mCondition ' !MemoryPoolStatic::get_singleton() ' is true. �[0;31m At: core/os/memory.cpp:59.�[0m
The problem is why the app gets terminated in the first place after the home button press.
... console: * will resign active console: **** stop animation! console: * did enter background (something happens here that causes iOS 11 to terminate the app) console: ***** will terminate console: iphone_finish ...
I also tested the same app on an iOS 10 simulator and it wasn't terminated, and therefore, it stayed in its background state.
... console: * will resign active console: **** stop animation! console: * did enter background ...
I also tried to set the "Application does not run in background (UIApplicationExitsOnSuspend)" Boolean to "NO" in the project's info.plist but it did not help.
this stop the crash,but freezes the app when enter to foreground and then crash
and where does it crashes after entering foreground?
I also tried to set the "Application does not run in background (UIApplicationExitsOnSuspend)" Boolean to "NO" in the project's info.plist but it did not help.
I think iOS11 is just ignoring UIApplicationExitsOnSuspend
and quitting the application anyways. Maybe UIBackgroundModes
could help.
I tested UIApplicationExitsOnSuspend
with a demo Unity project on iOS 11 device and it behaves appropriately.
With NO
:
-> applicationWillResignActive() -> applicationDidEnterBackground()
With YES
:
-> applicationWillResignActive() -> applicationDidEnterBackground() -> applicationWillTerminate()
Therefore, I do not think that iOS 11 ignores this setting. UIBackgroundModes
are for background services, in our case the app should just stay in its background state without any further code execution after applicationDidEnterBackground
.
I see, maybe our applicationDidEnterBackground
is the problem.
It does not stop crash, it just delay the crash after enter to background. And the AudioDriverIphone::finish called twice.
AudioDriverIphone::finish AudioDriverIphone::finish (lldb) bt
MemoryPoolStaticMalloc::_free(this=0x00000001c027bac0, p_ptr=0x000000010806c420) at memory_pool_static_malloc.cpp:294 frame #1: 0x0000000104f7f630 godot_opt.iphone
MemoryPoolStaticMalloc::free(this=0x00000001c027bac0, p_ptr=0x000000010806c420) at memory_pool_static_malloc.cpp:230
frame #2: 0x0000000105ae2428 godot_opt.iphoneMemory::free_static(p_ptr=0x000000010806c420) at memory.cpp:60 frame #3: 0x0000000104bf0790 godot_opt.iphone
void memdelete_arrAudioDriverIphone::finish(this=0x00000001c00cd680) at audio_driver_iphone.cpp:186 frame #5: 0x000000010592474c godot_opt.iphone
AudioServerSW::finish(this=0x00000001114a0020) at audio_server_sw.cpp:779
frame #6: 0x0000000104bed5a4 godot_opt.iphoneOSIPhone::finalize(this=0x000000010805b000) at os_iphone.cpp:376 frame #7: 0x0000000104c2c12c godot_opt.iphone
Main::cleanup() at main.cpp:1671
frame #8: 0x0000000104beb980 godot_opt.iphoneiphone_finish() at godot_iphone.cpp:88 frame #9: 0x0000000104bf8288 godot_opt.iphone
::-[AppDelegate applicationWillTerminate:](self=0x00000001c422b0a0, _cmd="applicationWillTerminate:", application=0x0000000107a04c40) at app_delegate.mm:681
frame #10: 0x000000018fdefbfc UIKit-[UIApplication _terminateWithStatus:] + 228 frame #11: 0x000000019025eb04 UIKit
98-[UICanvasLifecycleMonitor_Compatability deactivateEventsOnly:withContext:forceExit:completion:]_block_invoke.271 + 344
frame #12: 0x000000018ffd8680 UIKit_runAfterCACommitDeferredBlocks + 292 frame #13: 0x000000018ffcbb24 UIKit
_cleanUpAfterCAFlushAndRunDeferredBlocks + 288
frame #14: 0x000000018fd5a808 UIKit_afterCACommitHandler + 132 frame #15: 0x00000001868ff8b8 CoreFoundation
CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 32
frame #16: 0x00000001868fd270 CoreFoundation__CFRunLoopDoObservers + 412 frame #17: 0x00000001868fd82c CoreFoundation
__CFRunLoopRun + 1292
frame #18: 0x000000018681e2d8 CoreFoundationCFRunLoopRunSpecific + 436 frame #19: 0x00000001886aff84 GraphicsServices
GSEventRunModal + 100
frame #20: 0x000000018fdcb880 UIKitUIApplicationMain + 208 frame #21: 0x0000000104bf4d6c godot_opt.iphone
main(argc=1, argv=0x000000016b34f858) at main.m:45
frame #22: 0x000000018634256c libdyld.dylib`start + 4
(lldb) It seems the code in the patch has free the same memory multiple times.
It does not stop crash, it just delay the crash after enter to background. And the AudioDriverIphone::finish called twice.
Try this, remove the audio_driver->finish();
line at OSIPhone::finalize()
.
I have tried it hours ago.
The crash is triggered in this method:
(void)applicationWillTerminate:(UIApplication *)application {
printf("***** will terminate\n");
[self deinitGameControllers];
if (motionInitialised) { ///@TODO is this the right place to clean this up? [motionManager stopDeviceMotionUpdates]; [motionManager release]; motionManager = nil; motionInitialised = NO; };
iphone_finish(); };
Because when enter to background on iOS 10, this callback will not called, but on iOS 11 it is called. You can mimic to call this method on iOS 10 to debug it.
Maybe some memory has already been corrupted when enter to background cause the application I’llterminate get called.
I haven't dived far enough into things but I think the problem with the iOS setup is that Apple has changed the way this worked several times over time and some of the Godot iOS code seems to be from an earlier time.
Originally until the iPhone 4 (I think it was) came out an application that goes into the background would be terminated as multitasking wasn't supported. Then when you went back to the application it would reload and you as a developer where tasks to bring it back into the state it was before it closed.
When multitasking got added they added new methods that signal your application that it would go into the background but wouldn't terminate your application. Many applications never implemented those keeping the application running at full steam in a background thread waisting your battery in no time so Steve Jobs could tell us "see, this is why we were against multitasking on a phone".
My guess is that they've probably introduced a new keyword in the plist that tells the OS whether to terminate an app when it goes into the background or whether it can keep a background thread alive. Dunne know, guessing here.
Be as it may, I've noticed cleanup isn't Godots strong point here. It's probably worth having a closer look at all the notifications that main application delegate gets and moving things around into the right place so things that need to get paused get paused and things that need to terminate get properly stopped and deallocated.
Btw, @marcelofg55,
it makes sense audio server gets destructed twice. In your changes you are cleaning it up in iPhone finish, but it is already being cleaned up in Main::cleanup()
OSIPhone::finalize should only clean up objects that were created in OSIPhone::initialize
What I do find interesting is that the audio server gets destructed before finalize gets called (it also gets called from Main::cleanup), so there might be an issue as well as the audio driver gets destructed in finalize and may call back into the audio server which by this point no longer exists.
@reduz is the audio server meant to clean up any drivers automatically or should we move the cleanup code: https://github.com/godotengine/godot/blob/master/main/main.cpp#L1765 Till after finalize gets called here: https://github.com/godotengine/godot/blob/master/main/main.cpp#L1775
?
@BastiaanOlij You're thinking about master but this is for 2.1, on 2.1 Main::cleanup
there is no audio_server->finish()
, all the OS::finalize()
of each OS call the audio_server->finish()
. The only one that missed this call is the iPhone code.
I've re-checked my changes and I think I found the issue, the spatial_sound_server/spatial_sound_2d_server must be finished before finishing the audio_server. I've re-tested a few times and didn't get any crash using a iPhone 6 with iOS 11.0.1. Changes are this branch: https://github.com/marcelofg55/godot/tree/iphone_crashfix
@marcelofg55 my bad, yes I was purely looking at master... Though reading that, good change that on master this will cause issues as well due to the audio server being finished too early. I can't test right now but worth having a look at.
I think master shouldn't have this problem as that part got re-written but yeah we should test it just in case, I'll give it a try out tomorrow, if you can test it out too that would be great :).
Owh I still have plenty of instability and crashes on iOS on master so there is definitely more to figure out. But my focus is currently on other things so I need to find time :)
@marcelofg55 https://github.com/marcelofg55/godot/tree/iphone_crashfix It still terminate when enter to background.
2017-10-03 12:05:34.685824+0800 godot_opt.iphone[5898:2645519] refreshPreferences: HangTracerEnabled: 0 2017-10-03 12:05:34.685898+0800 godot_opt.iphone[5898:2645519] refreshPreferences: HangTracerDuration: 500 2017-10-03 12:05:34.685929+0800 godot_opt.iphone[5898:2645519] refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0 did become active 2017-10-03 12:05:34.918026+0800 godot_opt.iphone[5898:2646133] [BoringSSL] Function boringssl_context_get_peer_sct_list: line 1754 received sct extension length is less than sct data length 2017-10-03 12:05:35.789756+0800 godot_opt.iphone[5898:2645933] [BoringSSL] Function boringssl_context_get_peer_sct_list: line 1754 received sct extension length is less than sct data length [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;33mWARNING: _png_warn_function: [0m[1miCCP: known incorrect sRGB profile [0;33m At: drivers/png/image_loader_png.cpp:66.[0m [1;31mERROR: get_node: [0m[1mNode not found: shield [0;31m At: scene/main/node.cpp:907.[0m will resign active **** stop animation! did enter background will terminate iphone_finish [1;31mERROR: action_release: [0m[1mCondition ' !custom_action_press.has(p_action) ' is true. [0;31m At: main/input_default.cpp:483.[0m [1;31mERROR: add_child: [0m[1mParent node is busy setting up children, add_node() failed. Consider using call_deferred("add_child", child) instead. [0;31m At: scene/main/node.cpp:719.[0m killed_ememy_scores [100, 0, 0, 0] [1;31mERROR: add_child: [0m[1mParent node is busy setting up children, add_node() failed. Consider using call_deferred("add_child", child) instead. [0;31m At: scene/main/node.cpp:719.[0m [1;31mERROR: ~List: [0m[1mCondition ' _first != null ' is true. [0;31m At: core/self_list.h:80.[0m [1;31mERROR: ~List: [0m[1mCondition ' _first != null ' is true. [0;31m At: core/self_list.h:80.[0m [1;33mWARNING: cleanup: [0m[1mObjectDB Instances still exist! [0;33m At: core/object.cpp:1845.[0m [1;31mERROR: clear: [0m[1mResources Still in use at Exit! [0;31m At: core/resource.cpp:378.[0m [1;31mERROR: free_static: [0m[1mCondition ' !MemoryPoolStatic::get_singleton() ' is true. [0;31m At: core/os/memory.cpp:59.[0m [1;31mERROR: free_static: [0m[1mCondition ' !MemoryPoolStatic::get_singleton() ' is true. [0;31m At: core/os/memory.cpp:59.[0m [1;31mERROR: free_static: [0m[1mCondition ' !MemoryPoolStatic::get_singleton() ' is true. [0;31m At: core/os/memory.cpp:59.[0m
I totally agree with @hjegor
The problem is why the app gets terminated in the first place after the home button press.
The code change fix the crash when application will terminate, but the issue cause the termination when enter to background still exist.
Could it be a scons build
problem?
Because I removed the whole Godot part and only left the iOS specific stuff (app_delegate.mm
, gl_view.mm
) and it still gets terminated after the home button press...
Also, I receive the following error while I am trying to run the x86 build on my iOS11 simulator: dyld: dyld_sim is not compatible with the loaded process, likely due to architecture mismatch
even replace gl_view with a UIView still cause termination. This issue and #11628 make the stable 2.1 branch impossible for iOS products. Could any contributor proficient at iOS check these issues?
TEMPORARY FIX The solution in this forum post actually works for Godot as well. https://forums.adobe.com/thread/2387025
No code changes are needed to make this work on compile.
Run the following (tested on 2.1 & 2.1.4-stable branches):
scons p=iphone -j 4 target=release tools=no arch=arm64 bits=64 IPHONESDK="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/"
The important part is pointing the iPhoneSDK to the symlinked location instead.
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/
Now when the app is suspended/backgrounded, it will not crash and resumes as expected :)
Yes, amazing. It's fixed now!
@fuzzeemic, Thanks very much, you are the hero!
It's really amazing. All the orientation issues are also fixed by this.
So should we change the default IPHONESDK
value, or will that break templates for iOS 10?
@akien-mga I think it's a safe change to make as it fixes most peoples current problems with the latest xcode and you can always override it on the command line back to whatever you want for older builds. (But I am only new here, so not sure on peoples workflow yet)
Yes, it works now!
Thank you @fuzzeemic !!!
@marcelofg55 @BastiaanOlij Thoughts on bumping the IPHONESDK
value?
I think these two headache issues have also been fixed by this magic. At least I have tested on some iOS 11 and iOS 10 devices.
I'm trying to compile ios template on ubuntu.
now I got error below.
$ scons -j 1 platform=iphone arch=arm64 IPHONESDK="/mnt/2TB/Development/iPhoneSDK/iPhoneOS11.0.sdk" IPHONEPATH="/mnt/2TB/Development/iostoolchain" ios_triple="arm-apple-darwin11-"
scons: done reading SConscript files.
scons: Building targets ...
[ 5%] Compiling ==> platform/iphone/gl_view.mm
In file included from platform/iphone/gl_view.mm:30:
In file included from platform/iphone/gl_view.h:31:
In file included from /mnt/2TB/Development/iPhoneSDK/iPhoneOS11.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h:22:
In file included from /mnt/2TB/Development/iPhoneSDK/iPhoneOS11.0.sdk/System/Library/Frameworks/AVFoundation.framework/Headers/AVAnimation.h:11:
In file included from /mnt/2TB/Development/iPhoneSDK/iPhoneOS11.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:128:
/mnt/2TB/Development/iPhoneSDK/iPhoneOS11.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUUID.h:26:49: error: nullability specifier '_Nullable' cannot be applied to non-pointer type 'uuid_t' (aka 'unsigned char [16]') [17]
- (instancetype)initWithUUIDBytes:(const uuid_t _Nullable)bytes;
^
/mnt/2TB/Development/iPhoneSDK/iPhoneOS11.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSUUID.h:29:30: error: nullability specifier '_Nonnull' cannot be applied to non-pointer type 'uuid_t' (aka 'unsigned char [16]') [17]
- (void)getUUIDBytes:(uuid_t _Nonnull)uuid;
^
2 errors generated.
scons: *** [platform/iphone/gl_view.iphone.opt.debug.arm64.o] Error 1
scons: building terminated because of errors.
I found somethings are changed from 10.x to 11 http://codeworkshop.net/objc-diff/sdkdiffs/ios/11.0/Foundation.html how can I fix it? nobody suffers this issue?
compiling problem is gone after updating clang to 4.0 (rc1) :)
@fuzzeemic That's promising. By the way, is it possible to include list of architecture to build for at the same time in scons
i.e. scons p=iphone -j 4 target=release tools=no bits=64 arch=arm64,armv7
? So we could save time to just execute command for one time and have fat binary for both architecture at the end? cc: @akien-mga
Is this still valid in the current master branch? How can we fix this properly?
@akien-mga I have an idea as follows assumed that machine that proceeds with this should be macOS. Anyway can we build iOS build with Windows or Linux anyway?
xcode-select -p
. It will output something like this /Volumes/Slave/Applications/Xcode9/Xcode.app/Contents/Developer
./Volumes/Slave/Applications/Xcode9/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
which will have iPhoneOS11.2.sdk/
or other versions.scons
.PS. As well we could force changing the active SDK path via sudo xcode-select -s /Volumes/Slave/Applications/Xcode8/Xcode.app/Contents/Developer
but it needs administrator permission. Just in case, if we ever need this to do any customized stuff.
Operating system or device, Godot version, GPU Model and driver (if graphics related): godot 2.1 iOS 11.0.1
Issue description:
Run any Godot app on a device of iOS 11, then press home button to enter to background, it will crash This only happens on iOS 11, before iOS 11 it work well.
here is the backtrace:
Steps to reproduce:
Link to minimal example project: