ARKit crashes on internal Assert in "MovingIMUCameraDiscrepancyClassifier.cpp" - arkit

I am developing an app which uses the "Motion Capture" feature of ARKit/RealityKit. At least since iOS 16 it often crashes after a few seconds due to an Assert in Apples C++ code, even in release mode. I am pretty stuck right now. The console log reads:
Assert: /Library/Caches/com.apple.xbs/Sources/AppleCV3D/library/VIO/Odometry/src/MovingIMUCameraDiscrepancyClassifier.cpp:37 : current_state_timestamp > last_update_timestamp_
So it is pretty clear what fails, but what can I do about it?

Related

How to debug if app closes without error message?

Im facing an issue that i am unable to debug.
If i open the app, it opens normally and works. But if i launch the app and close the app within 1 second and then launch the app again, it crashes without error message.
How do i debug this as Xcode loses debug connection if i close the app?
I tried putting exception break point but since xcode loses debug connection, it wont trigger.
This ONLY happens when a user does the above mentioned steps (open, close within 2 seconds and open again).
Is there anyway to find out why the app is closing and why there is no error / crash message?
Clarification : The crash happens when user opens the app, within 1 sec terminates the app by manually by swiping up from recents menu and tries to open the app again within 1 or 2 seconds. (Open -> terminate -> open)
Let us imagine that you run the app and quickly force-quit. Then, if you start your second run of the app from the Xcode debugger, hopefully, you should see your crash in Xcode at that point.
If that does not work, you might consider a crash reporting tool (e.g., Crashlytics, etc.). That will help you monitor and track crash reports that happen (for both you and your users) in the wild. If you do this, make sure you test the crash reporting system with some forced crash/report because an absence of a report could just be a result of a misconfiguration, which is easy to do because the setup of these tools takes a little work the first time you do it. Just make sure you have the crash report system working with a positive crash report before you draw any conclusions from an absence of a crash report generated by this particular bug.
That having been said, the way these crash reporting systems often work is they capture the crash and send it the next time you start up the app. It seems like there might be a chance that your particular crash (firing it up after having quickly force-quit it the first time) is happening so fast that the crash reporting system may not have a chance to send off its report of the past crash. (That having been said, these are still invaluable for capturing information about user crashes that happen during the normal use of the app, so I would consider them even if it does not help in this particular scenario.)
So, let’s imagine that you are still unsuccessful in catching your crash for some reason. The last resort is to consider sprinkling your code with Logger/OSLog statements. The nice thing about these logging statements is that you can watch these logging statements on your macOS Console app. See WWDC 2020 Explore logging in Swift.

Where Can I Intercept NSXPCConnectionInterrupted?

OK. I have an app that is in regular communication with a Watch.
They are running apps that can do iOS 10.0 or greater, and WatchOS 3.0 or greater. I don't care about less.
When the iOS app gets shoved into the background, comms to the Watch get interrupted, and I start seeing log entries that mention NSXPCConnectionInterrupted, which is a standard Foundation error.
I have a couple of issues:
1) Where can I intercept this error? It doesn't seem to be showing up in my callbacks or delegate methods.
2) This is not a question. It's just an annoyance. In the simulator, I don't get this. It only happens in the device itself. I didn't encounter it until I was at a point where I could actually install and run on-device.

cocos-2d:My app crashes when i close it via task manager

I have Weird problem,When i close my app via task manager , my app gets crashed on the line
int retVal = UIApplicationMain(argc, argv, nil, #"AppDelegate");
throwing "Thread : 1 signal SIGKILL" error,and i can't reopen my app at all. other times it works pretty well.
Please some one help me with this problem.
I am new to cocos-2d so please be gentle :( , thanks.
As far as I know, this is normal, expected behavior. The reason it seems weird, I think, is that when you run from Xcode, your executable is attached to the debugger in Xcode, so it sometimes prevents things from executing (for example, in a crash or SIG_KILL scenario). This is just giving you a hint as to what apple is doing when you use the task-bar to close the app... it sends SIGKILL to the process :-)
EDIT: for the curious, I tested a little and found that applicationWillTerminate: is not called first, which is actually encouraging as a consumer of apps. You really are SIGKILLing these things. I think this means (with the background-processing workflow) that the only case when that method will be called is if you opt out of background execution. The good news is that in order to kill an app this way, you need to move it to the background first, so the canonical place for teardown is applicationWillResignActive: but you knew that...
EDIT: instructions for avoiding the can't-run-again issue:
Build and Run the app on your device from Xcode
As soon as the app is "up and running", click "stop" in Xcode
When the app has closed, it is now "detached" from Xcode and you can terminate it and re-open as often as you wish. Just keep in mind that it will no longer log to Xcode any NSLog calls or otherwise.

iPhone camera application running fine in iPhone but crashing in iPod

i made an iPhone app that uses camera. It works fine in iPhone, no memory warnings at all. It is also running on iPod touch 4G but gives memory warnings and crashes after some time after getting level 2 warning.
If someone can point me the possible reason for this. Thanks.
The only way you are going to fix this is by being able to debug it on the device. I wrote this blog to explain how to debug EXC_BAD_ACCESS, which is what I assume you are getting
http://loufranco.com/blog/files/Understanding-EXC_BAD_ACCESS.html
The simplest things to do:
Run a Build and Analyze and fix every problem it finds (or at least rewrite it so that B&A doesn't think it's a problem) -- Having a clean B&A is a really good way to making sure you catch these problems early
Turn on Zombies and run your program -- this makes the last release sent to an object turn it into a zombie rather than dealloc it. Your program will leak tons of memory, but if you ever send a message to a zombie it will stop right there and you will see a bug that you need to fix, because in your real version, that would be a crash (sending a message to a dealloced object).
More techniques described at the link
It crashes on a specific operation or randomly?
if randomly,
use instrument to check your memory leaks and memory usage. It's hard to figure out where the problem lies in without going through all your app.

Memory footprint of an app on iPhone

I recently had an app rejected from the app store because of Low Memory Exception. The app doesn't leak memory, but its base memory footprint seems to be too high. According to the crash logs sent by apple, it was taking about 14000 pages in the memory (mostly due to huge textures). There were 2 strange things though:
I tested it on 5 devices rigorously before submitting, and never got this crash on any one of them.
I did optimize the textures after the rejection, and brought them to about half the original size (texture memory consumption).
I have no way of knowing how many pages my app is taking now, unless I can reproduce the same crash as apple (which I never could). Is there another way to be able to find out the memory footprint of my app, so that I can be sure that it is optimized enough now.
I did try instruments, but my app crashes when I try to run it through my XCode (must be some problem with my XCode). But it works perfectly when I run it directly on my iPhones/iPods. Any help in finding out the memory footprint of my app on iPhone (if there is something analogous to task manager of windows), would be appreciated.
Thanks
EDIT:
Launching the app from XCode gives the following error in the console:
"Error launching remote program: failed to get the task for process 553."
Launching the app with Activity Monitor gives the following error:
"Target terminated too early to collect data"
EDIT2:
I was able to run my app with Activity Monitor, by using a dev profile instead of distribution profile. But now there are several sections in the Activity Monitor - Physical Memory Used, Real Memory, Virtual Memory. Which one of these do I consider. To sum it up, I need to know which one of these causes the iPhone to throw a Low Memory exception.
XCode -> Run -> Run With Performance Tool -> Activity Monitor.
If the device is connected, Activity Monitor runs on the iPhone/iTouch.
I think you're coming at this from the wrong angle. You're asking how to find the memory footprint without using XCode. I think the question you should be asking is: why can you not use XCode? Presumably that's what you used to develop the application in the first place?
Without XCode you're pretty much flying blind. You say you halved the size of your textures, but how do you know? Does your app release any extraneous memory when it gets a low memory warning? (applicationDidReceiveMemoryWarning:)
First, have you looked at the crash logs from when you run your app from XCode? You should be able to see them in the Organiser in XCode.
I'm not sure there's a single solution to stop your app crashing with XCode. Normally when my iPhone won't allow debugging I just restart xCode and my handset and it starts working again. Restarting XCode sometimes helps. I would also try reinstalling both XCode and the iPhone SDK.