Xamarin forms android application showing un-usual behavior and crashing - android

Recently around Dec 1st reset my pc and installed visual studio. Previously when I last installed visual studio, it showed Xamarin forms in the installation directory. This time it showed MAUI and provided Xamarin as an addon to work with Xamarin. Until this its fine. After installation, I was able to load Xamarin forms project properly. Now, when I deploy to the android device for debugging, everything worked fine. But as I interacted more, UI started misbehaving with stack layout or frame view elements not resizing.
Below screen shots will explain the situation
Normal Behavior
Parent page for the above page
When interacting with the page in the first picture, elements like stack layout and frame are not resizing.
When navigated from the current page to parent page, UI misbehavior continues
When clicked on an item in the above page, instead of getting page that looks like 1st pic, getting empty page
When navigated back still same mal-formed page
On turning off and on the screen, UI refreshing to normal.(Before any crash happens)
While the above process happens, anytime application is crashing particularly when any data was being updated on the UI.
Debug Logs when crashed
I presume this is a Xamarin renderer or some library issues. How do I over come this as my app is in production stage.
I tried to reinstall entire visual studio and also cleared all the cache of Xamarin and Android like NuGet packages etc. It the same result. A workaround would be good and a solution would be excellent.

Related

Shell performance in .NET MAUI (Android)

I decided to develop an app using .NET MAUI (xaml), that is now in RC. I use shell page as a base, and found out that there's a significant lag/glitch in a following scenario:
Open flyout menu
Click on some navigation button
Flyout menu starts closing. At this moment there's a glitch, like it tries to render a page you navigate to and close the menu in the same thread. The more complex page you have, the longer the glitch takes place. But even if you have a blank page, it still happens. I think it's either me doing it wrong or there are issues with .NET MAUI shell.
Looking through the Internet I found an issue in github about similar problem in Xamarin: https://github.com/xamarin/Xamarin.Forms/issues/7521 . I suppose it happens in MAUI because the issue migrated from Xamarin, but it's ridiculous that it hasn't been fixed for 2 years. There are some workarounds there, but all of them are not good for me to use.
Does anyone know how to resolve this app freeze in MAUI/Xamarin?
Also, is it possible to have a fully functional flyout menu in MAUI Blazor (a menu that can respond to swipe gestures)?
P.s. I don't attach the code as it's pretty basic, you can just add 2 blank pages to navigate to, and you'll notice the time delay when the menu closes. I test it on Samsung Galaxy A8.

Xamarin forms map crash on navigation away from map

I've made an app where I display a map. On the same page I also have a button. When the button is clicked I want to display a modal page to enter some data. It works except from Android, where the app crashes when I do the navigation. It's this issue https://forums.xamarin.com/discussion/81768/launching-a-modal-over-a-page-containing-a-map-maps-ad-m-cannot-be-cast-to-android-view-viewgroup
So far I haven't found a solution that fixes the issue. I'm running latest XF 2.3.4.247 stable
best regards

App is not maintaining the state after installation - Xamarin android

Recently I noticed one thing in my app.
I created apk for my app say ABC.apk and copied to my device and installed it by clicking on it. After the installation got successfully completed, I got 2 options 'Done' and 'Open', the usual options we get after installation.
I clicked on 'Open' and run the app. I moved to some screen and I minimized the app and moved to someother app, when I click my ABC, it started from my first screen.
It was just fraction of seconds I moved back to it, hence it should not be killed though launched it like it is first time.
Few things I noticed I if I explicitly killed this first instance from background running apps and start the app again it is not giving me this problem, same if I click 'Done' instead of 'Open' it works fine.
Is there anyone who are facing same issue, or have some solution for it?
Thanks in advance.
Prajakta
The problem is the way that the app gets launched from the installer doesn't exactly match the way Android launches apps from the HOME screen. Because this, if you initially launch your app from the installer, when you then later launch the app again from the HOME screen, Android doesn't recognize that the app is already running and just creates a new instance of the root Activity and adds it to the existing task on top of whatever activities are already there.
This is why, if you kill the app and start it again from the HOME screen, you won't ever see this strange behaviour.
This is a nasty Android bug which has been around since the dawn of time and is still broken, even though countless issues have been opened about it and the behaviour is reproducible and well-documented.
See the following issues and questions:
https://issuetracker.google.com/issues/36941942
https://issuetracker.google.com/issues/36907463
https://issuetracker.google.com/issues/64108432
App restarts rather than resumes
Re-launch of Activity on Home button, but...only the first time
There is a workaround documented in my answer to
Re-launch of Activity on Home button, but...only the first time
Just some general comments that come to mind that you must consider that can cause problems.
If you are trying to deploy an apk, did you switch from debug to release before building it? Make sure you are doing a full release. Do a clean and rebuild while in release mode as well.
Did you sign the apk?
Make sure all the necessary (if any) permissions are set in the manifest that will be needed by your app, on the device.
Hope these help point you in a direction.
Mike

Back navigation from WebBrowser form pops stack too many times - Android CodenameOne

Looking for advice here.
I have a simple empty Form in my UIBuilder app that puts a web browser component in the Center of its BorderLayout in its "beforeVideoScreen" method. it loads an external page (embedded Youtube link) set in code.
It will help my explanation for you to understand my forms hierarchy (all UI Builder based):
Main --> Categories --> Topics --> Details --> Video Viewer
On Samsung Galaxy Android devices (I have an SG3 running 4.4 and and SG6 running 5.1), when I am on the "Video Viewer" form and press the back button on the device, i see a strange visual effect - like back-navigating twice to the same screen. I arrive at the correct form (the "Details" form), but if I navigate back from "Details" all the steps to Main, it skips the Categories Form.
Now it gets interesting: If I go back and forth between "Video Viewer" and "Details" repeatedly, I eventually have NO back stack from the details form. (if I do the "Video Viewer" back to "Details" cycle this way twice, then 2 forms are missing, 3 times and 3 forms are missing etc) it just exits the app. Makes me think that it's double-dipping on the back-stack.
On the simulator and physical iOS device it does not exhibit this behaviour. if I remove the Web Browser component and instead place a static image, it doesn't exhibit this behaviour so it's not the UIBuilder/forms structure itself etc. It seems isolated to the WebBrowser component being on the screen when hitting the back key on the device.
So my question: I can't think of a way to troubleshoot this. Can anyone recommend either a way to troubleshoot this behaviour (native Android browser....) or any known issues/workarounds for it?
I've made a potential fix to address this issue, this is under review so I'm not sure if it's the "right thing":
https://github.com/codenameone/CodenameOne/commit/e5fb68fa881d680746a34134a368da91b71bc71b

Flashbuilder VideoDisplay error

I am currently building an app using Flashbuilder for an Android device.
On several pages I have a spark component videodisplay or videoplayer in the pages.
For whatever reason the first time I open the app and navigate to that page the video doesn't load.
If I move off that page and go back the video shows fine.
If I then lock the screen, and then go back to the app I again navigate to a page with a video and again it doesn't display on that first showing.
Extensive websearch etc and I cannot find anybody else with the same error.
trace() shows video loads fine, both in s:videodisplay and s:videoplayer.
Any help would be brilliant.
Fixed the problem
It would appear that this is actually a bug with the AIR SDK (Bug 3354849 on Adobe Bugbase refers)
The new version of SDK (3.7) now requires the following code added to the manifest file.
<containsVideo>true</containsVideo>

Categories

Resources