-
Notifications
You must be signed in to change notification settings - Fork 522
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
Random app crashes on publish in AOT mode #21908
Comments
From @mattleibow on Sat, 04 Jan 2025 14:18:54 GMT @rolfbjarne thoughts? |
From @mattleibow on Sat, 04 Jan 2025 14:22:56 GMT @jdarwood007 not sure if it matters, but are you using the interpreter? Have you set the |
From @mattleibow on Sat, 04 Jan 2025 14:24:32 GMT I found these issues:
Might be unrelated, might not be. |
From @jdarwood007 on Sat, 04 Jan 2025 15:44:23 GMT @mattleibow I do not have it defined in my .csproj, so no. Although a quick read on the documentation seems that this may be the reason because I use generics. I consume a REST API returning JSON results and it uses a standardized return with a property that has a defined type (so my return is something like I did enable However, I can get it to build and run successfully randomly and even have releases. My thoughts here are that something on the Visual Studio or Mac OS side is being held and retained during the build from a previous build and causing this. It is possible that a file is being cached improperly, a file stat call is returning cached results or a file is not recognized as needing to be rebuilt. For the linked issues, the first issue mentions The second issue was resolved with an update, but the change message indicates a different function than the one I'm seeing crashing. That is we are seeing The third linked issue isn't relevant, as their crash is caused by code they directly wrote, whereas from what I can tell, my issue occurs early on in the startup process, before my code can even execute. |
Yes, this certainly looks like a problem with incremental builds, where we don't correctly identify what needs to be rebuilt and what doesn't (which is why a clean build works: then everything will be rebuilt). The annoying part here is that these incremental build issues can be rather hard to track down, because we need very specific instructions in order to reproduce them: provide a test project (or your actual project if that's easier for you), and then something like:
|
The app is an internal app used for the business. I tested on another of our internal apps, currently on .net 8, and even after upgrading to .net 9 and doing testing, it worked flawlessly. Yet the first app (in this report) gave me trouble for weeks with random crashes. I even tried to mess with various build settings to determine if it was something during the linker doing something and accidentally stripping out a needed component. Unfortunately, building in dev and release mode has worked fine for the past week now. I don't have a build to send to test flight to verify if its still doing it. Oddly enough though, when I would build for release, it would sometimes work, but then sending it up to testflight and back down to the device would crash. Are there additional debugging steps I can try to do in order to produce more verbose information? Can I get the compiler to indicate what libraries/components it determines will not need to be updated and thus are skipped in the build output log? I don't see any from the output myself. |
Any problems with the linker would be consistent - i.e. cleaning wouldn't fix it.
Kind of, if you get an MSBuild binlog (https://github.com/xamarin/xamarin-macios/wiki/Diagnosis#binary-build-logs), it will typically be possible to deduce this by inspecting the binlog. However, the build process is rather complex, so it's not trivial. If you can get such a binlog, we could have a look and see if we find anything useful (note that figuring out that library X wasn't rebuilt correctly is only half the picture - we also need to know why library X should have been rebuilt, which means we need to know exactly what you did in your project). |
I received the crash again today while building. The error message this time was
This is interesting as I didn't touch anything related to the SQLite code or package between the last release and the one I am working on. I'm running the latest 2.1.10 for that Nuget package. The only code changes between my last two releases are XAML and some code behind for a component and page. As a test, I deleted everything in the folder on the mac located in: /Users/jeremy/Library/Caches/Xamarin/mtbs/builds/MyApp/ So the issue is related directly to something on the CreateIpa process I believe. I will try next time to selectively delete files on the mac side to see if I can't limit it down more. If you have suggestions let me know. I was able to generate the bin log for the build and CreateIpa process. Does the Bin log include what is occurring on the mac during its build? |
If you want to share privately, you can put it on a file-sharing service (say Dropbox), and then share a link to it ([email protected]). |
Hi @rolfbjarne. Due to inactivity, we will be closing this issue. Please feel free to re-open this issue if the issue persists. For enhanced visibility, if over 7 days have passed, please open a new issue and link this issue there. Thank you. |
@rolfbjarne can you reopen please? Bumping this as I can reproduce the same stack trace (or something very similar!) and it's causing major disruption for our customer, who is waiting for us to deliver functional changes that are blocked by AOT issues that have essentially appeared overnight with no obvious change to our csproj / packages / etc. |
@LordBenjamin if your problem goes away with a clean rebuild, then it's something else, and I would suggest creating a new issue where we can properly track it. |
The problem does not go away with a clean rebuild. It only goes away if I delete the SDK cache folder on the Mac (as per @jdarwood007 comment above) and then re-pair the Mac from Visual Studio. |
@LordBenjamin, perhaps you could help me track it down. I don't have any planned releases of my app right now, so its bug fixes only that would trigger me to build a new version. On a recent build, I did last month, I got the following error:
I deleted on the mac cache folder: A week later I had to send another bug fix up and I tried and got another error:
I am using that library, but I know it hasn't changed. However, I think my visual studio did have an update. So perhaps related? Using what I learned from the last test I tried to delete: So then I tried to delete the following:
This one was weird as Visual Studio started to indicate a file was missing. I did a clean solution and rebuilt it. The application still crashed. I then tried to delete all I rebuilt the app and then it was successful and didn't crash. However, I had to rebuild again after reverting as I did some library updates and something in the community toolkit was breaking the app and didn't want to load pages. I reverted and didn't do any tracing into why. I did a clean solution during that. That is as far as I have got with tracking down at least what files are being held over that is causing this. I am not certain if what I am doing is even helping. I figured at least if we can find the location of the files that are not being rebuilt, that the build process can be looked at for those files and determine if it is. It's possible just the nativelibraries folder is the problem and deleting just the affected file in it would help. I am trying to understand the file structure as it comes down to the Mac. As I said there was a "C" folder representing the C:\Users\jeremy\source\Repo\App as it matches on the Windows system. There is also a separate bin and obj folder. Which I would expect. Inside the bin/obj folders, we have the expected net9-ios folder, and inside there is which device I am building against, typically it is just Unless we can get some better tools to help us along with the build process to output some additional information, I think I am left with trying to slowly track down which directory has the affected files and fix the issue once deleted. From there, hopefully, I can provide information to help the devs understand why the build process does not think the file needs to be rebuilt when it does. Hopefully, as well we can figure out why a clean solution isn't cleaning up this. |
Same problem here |
From @jdarwood007 on Tue, 31 Dec 2024 19:55:39 GMT
Description
Random app crashes on publish in AOT mode
I am randomly getting app crashes in my app, only in release mode and only after sending to the App store and running in TestFlight on a physical device. Making this very difficult to get debugging information.
The problem seems to go away randomly as well. I can sometimes get the error to go away after a few times of cleaning and building the solution. It is inconsistent in what I do to fix it. However I have determined that even with no code changes in my app, after a few times of rebuilding and cleaning that I can send the exact same code up and have it not crash.
I got a crash report and had all symbols stripped. So I've added this to my .csproj
This resulted in me being able to get this stack trace:
It seems the app is hitting
mono_exception_from_name_two_strings_checked
early on in the startup of my app, as indicated the code is in the main and xamarin triggered the faulty code.I hooked up the device to a Mac mini and was able to get the console to present the following error message
This seems to back the results of what I am experiencing in that the crash is occurring randomly and that cleaning fixes it, by possibly removing that out of date dependency.
To resolve the crashes, I have done the following, all sometimes work and at other times does not resolve the issue.
I don't have any project to provide, as it is random and by luck I feel, will just work for a bit. I've seen this on a few projects I work with and the resolution has always been the same, try to clean things and rebuild until it works.
I have noticed that more often than not, the problem seems to exist after I deployed a the app to the device via TestFlight , if I plug it into the mac and deploy the app in debug mode, unplug device, clean, rebuild and publish the app into TestFlight and install the TestFlight version, it will crash.
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
9.0.21 SR2.1
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
Any
Did you find any workaround?
No response
Relevant log output
Copied from original issue dotnet/maui#26890
The text was updated successfully, but these errors were encountered: