The app crashes when sent to background

Hi,
I implemented the new Application.Current.RequestedThemeChanged event to detect when the app needs to change the style.

So I added following to the App.xml.cs file

public App()
{
 ...
Application.Current.RequestedThemeChanged += (s, a) => { SetTheme(a.RequestedTheme); };
}

The event, once triggered, is performing following action.

private void SetTheme(OSAppTheme appTheme)
        {
            try
            {
                switch (appTheme)
                {
                    case OSAppTheme.Dark:
                        Current.Resources = new DarkTheme();
                        break;
                    case OSAppTheme.Light:
                        Current.Resources = new LightTheme();
                        break;
                    case OSAppTheme.Unspecified:
                        Current.Resources = new LightTheme();
                        break;
                }
            }
            catch(Exception exc)
            {
                Debug.WriteLine($"Error while switching theme {exc.Message}");
            }
        }

So, now when I'm leaving the page where the SfCircularGauge is on (Shell navigation to another page), and send the app in background, an exception is caused.

Cannot access a disposed object.
Object name: 'SFCircularScale'.

I'm testing it on iOS with a simulator, however it also happens on real iOS devices. That's because I added a try {} catch block to it.
Is this a problem from Xamarin or from your control? Just seems to happen with the SfCircularGauge.
Both are used at this page.

This is how my XAML for the scale is looking like:

<gauge:SfCircularGauge.Scales>
                                                                                                <gauge:Scale 
                                                                                                        LabelFontSize = "{OnPlatform Android=10, iOS=12, Default=10 }" 
                                                                                                        LabelFont="{StaticResource Montserrat-Regular}"
                                                                                                        ShowRim = "False" LabelOffset = "0.85" 
                                                                                                        StartValue = "0" EndValue = "{Binding LimitExtruder}" Interval = "{Binding ExtruderInterval}" 
                                                                                                        RimThickness="28" 
                                                                                                        MinorTicksPerInterval ="4"
                                                                                                        LabelColor="{DynamicResource Gray-Black}"
                                                                                                        >
                                                                                                    <gauge:Scale.Pointers>
                                                                                                        <gauge:NeedlePointer Value="{Binding SelectedExtruder.TempRead}" Color="{DynamicResource Gray-Black}" 
                                                                                                                            KnobColor="{DynamicResource Gray-Black}" KnobStrokeColor="{DynamicResource Gray-Black}"/>
                                                                                                        <gauge:RangePointer Value="{Binding SelectedExtruder.TempRead}" Color="{DynamicResource PrimaryColor}"
                                                                                                                        RangeCap="Both"
                                                                                                                        />
                                                                                                        <gauge:MarkerPointer Value="{Binding SetExtruderTemp}" Color="{DynamicResource Red}"/>
                                                                                                    </gauge:Scale.Pointers>
                                                                                                    <gauge:Scale.MajorTickSettings>
                                                                                                        <gauge:TickSettings Thickness="1" EndOffset="0.73" StartOffset="0.65" Length="8" Color="{DynamicResource Gray-Black}"/>
                                                                                                    </gauge:Scale.MajorTickSettings>

                                                                                                    <gauge:Scale.MinorTickSettings>
                                                                                                        <gauge:TickSettings  Thickness="0.7"  EndOffset="0.69" StartOffset="0.65" Color="{DynamicResource Gray-Black}"/>
                                                                                                    </gauge:Scale.MinorTickSettings>

                                                                                                    <gauge:Scale.Ranges>
                                                                                                        <gauge:Range StartValue = "0" EndValue = "{Binding LimitExtruder}" Thickness = "18" Offset = "0.6">
                                                                                                            <gauge:Range.GradientStops>
                                                                                                                <gauge:GaugeGradientStop Value="0" Color="{StaticResource TempLow}"/>
                                                                                                                <gauge:GaugeGradientStop Value="{Binding MiddleExtruder}" Color="{StaticResource TempMiddle}"/>
                                                                                                                <gauge:GaugeGradientStop Value="{Binding LimitExtruder}" Color="{StaticResource TempHigh}"/>
                                                                                                            </gauge:Range.GradientStops>
                                                                                                        </gauge:Range>
                                                                                                    </gauge:Scale.Ranges>

                                                                                                </gauge:Scale>

                                                                                            </gauge:SfCircularGauge.Scales>

Thanks for helping out!

5 Replies 1 reply marked as answer

RS Ramya Soundar Rajan Syncfusion Team November 3, 2020 02:27 PM UTC

Hi Andreas Reitberger, 
 
Greetings from Syncfusion. 
 
We have checked the reported query in SfCircularGauge sample based on the provided code snippet. But it’s works fine in our side. 
 
Testing scenarios:  
 
·       Checked in a simple SfCircularGauge sample with the provided code snippet. 
·       Checked with the Shell sample and changed the theme while page navigation. 
·       Checked with different XF version. 
 

Configuration details: 

iOS version: 12.0 
Syncfusion Version: 18.3.0.44 
Xamarin Forms Version: 4.7 and 4.8

Can you please check the attached sample and please Share the following details? 

 
·       Please provide the parent view structure where the SfCircularGauge added.  
·       If possible, could you please share the sample to replicate this issue or modify the above sample along with device configuration. 
·       Is it occurred with the specific devices or else to common? In addition, please share the used device. 
·       Can you please provide the whole structure which is used in your application?

 
This will be helpful for us to investigate further and provide you a better solution at the earliest. 
 
Regards, 
Ramya S 



AR Andreas Reitberger November 4, 2020 03:55 PM UTC

Hi,
thanks for your sample project. Indeed, it doesn't hapen if you open the page as child window of the current navigation page.
However, if you switch the pages in the Shell flyout, it crashes.

I modified the sample so that the crash appears. Just set a breakpoint in the catch() block. Then, run it on iOS, open the flyout menu and switch to the "Page" via the flyout menu. Then, when the "Page" is loading / loaded, send the app in the background with the home button.





Attachment: GaugeShellSample1661183844_mod_3049030.zip


BK Bharathiraja K Syncfusion Team November 9, 2020 03:08 AM UTC

Hi Andreas, 
 
We can reproduce the reported issue our side. Currently we are validating the issue with our source and update you further details on November 10.  
 
Regards, 
Bharathiraja. 



RS Ramya Soundar Rajan Syncfusion Team November 10, 2020 02:02 PM UTC

Hi Andreas, 
 
We have considered the reported problem as an issue. We have logged the feedback link to track the status of the reported issue and the fix will be included in our weekly NuGet which is expected to be rolled out on November 17, 2020. We appreciate your patience until then.   
 
You can now track the status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.    
   
     
Note: The provided feedback link is private, and you need to login to view this feedback.    
 
Regards, 
Ramya S 



RS Ramya Soundar Rajan Syncfusion Team November 19, 2020 02:24 PM UTC

Hi Andreas, 
 
We are glad to announce that our weekly NuGet was rolled out and fix for the reported issue was included in the weekly NuGet. 
 
NuGet Version: 18.3.0.50
 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Ramya S 


Marked as answer
Loader.
Up arrow icon