Large text label in scroll view crashes the app

I have a label with large text inside a scroll view, when I scroll fast it's crashing the app. In the debug mode also it's not breaking at any error, but just crashes. Please help. Below is my code

<controls:ZoomableScrollView MinimumZoomScale="0.1"
                                 MaximumZoomScale="5"
                                 Grid.Row="1"
                                 Grid.Column="0"
                                 Padding="10" >
      <controls:TeluguLabel Text="{Binding Data.SthotramData}" TextColor="Black"   FontSize="{Binding LabelFontSize}"   >
        <controls:TeluguLabel.FontFamily>
          <OnPlatform x:TypeArguments="x:String">
            <OnPlatform.iOS>gautami</OnPlatform.iOS>
            <OnPlatform.Android>gautami.ttf</OnPlatform.Android>
            <OnPlatform.WinPhone>/Assets/fonts/gautami.ttf#Gautami</OnPlatform.WinPhone>
          </OnPlatform>
        </controls:TeluguLabel.FontFamily>
      </controls:TeluguLabel>
    </controls:ZoomableScrollView>

IOS renderer for ZoomableScrollView

[assembly: ExportRenderer(typeof(ZoomableScrollView), typeof(ZoomableScrollViewRenderer))]
namespace Sthotraani.iOS.CustomControls
{
    public class ZoomableScrollViewRenderer : ScrollViewRenderer
    {
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);
            if (e.NewElement == null)
                return;

            if (e.OldElement == null)
            {
                ZoomableScrollView zsv = Element as ZoomableScrollView;
                this.MinimumZoomScale = zsv.MinimumZoomScale;
                this.MaximumZoomScale = zsv.MaximumZoomScale;
                this.ViewForZoomingInScrollView += (UIScrollView sv) => { return this.Subviews[0]; };
            }
        }
    }
}

controls:TeluguLabel has no renderer it's created for android font setup.

Answers

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @ManikantaPratapVarma - I would install something like HockeyApp to monitor application crashes. These can still give you a stack trace to determine the source of the error. Once you have an error we can then get to fixing it.

    Or you can look to breakpoint if you manage unhandled exceptions. Unhandled exception handling in iOS and Android with Xamarin

  • @AdamP Thank you will try to embed to implement the unhandled exception and get back to you.

  • @AdamP
    I have followed the unhandled exception article and implemented it, Buy app never break's there. But still crashes

  • Hi @AdamP could you please help me with this issue

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @ManikantaPratapVarma - in this case the crash information should be present in your logs.

    Check out Where can I find my version information and logs? to find your local log and see what errors it has reported inside.

  • @AdamP the debug log is kept in the link below, I see a couple of memory warning, which I couldn't figure out why. Please help me figure out this. My app name is "Sthotraani"

    http://padfly.com/nandloganu

    Also I have pin pointed some.

    Jul 20 16:17:32 NarayananugrahamFeb-17-2013 SthotraaniiOS[2688] : Received memory warning.
    Jul 20 16:17:32 NarayananugrahamFeb-17-2013 SthotraaniiOS[2688] : LaunchServices: disconnect event received for service com.apple.lsd.mapdb
    Jul 20 16:17:32 NarayananugrahamFeb-17-2013 SthotraaniiOS[2688] : LaunchServices: disconnect event received for service com.apple.lsd.advertisingidentifiers

    Jul 20 16:17:32 NarayananugrahamFeb-17-2013 mediaserverd[989] : '' com.chirravuris.sthotraani(pid = 2688) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None

    Jul 20 16:17:33 NarayananugrahamFeb-17-2013 SpringBoard[177] : HW kbd: Failed to set (null) as keyboard focus

    Jul 20 16:17:33 NarayananugrahamFeb-17-2013 mediaserverd[989] : '' com.chirravuris.sthotraani(pid = 2688) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None
    Jul 20 16:17:33 NarayananugrahamFeb-17-2013 SpringBoard[177] : UNNotificationRegistrarConnectionListener connection invalidated
    Jul 20 16:17:33 NarayananugrahamFeb-17-2013 com.apple.xpc.launchd[1] (com.apple.lsd) : Service only ran for 0 seconds. Pushing respawn out by 1 seconds.
    Jul 20 16:17:33 NarayananugrahamFeb-17-2013 SpringBoard[177] : Application 'UIKitApplication:com.chirravuris.sthotraani[0x3cde]' was killed by jetsam.

    Jul 20 16:17:33 NarayananugrahamFeb-17-2013 UserEventAgent[23] : 4037225487140: id=com.chirravuris.sthotraani pid=2688, state=0

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @ManikantaPratapVarma - well there is the error, it is jetsam. Jetsam is an iOS process that kills any iOS application that isn't been a good memory citizen. If your app is asking for lots of memory and not releasing much, jetsam will come along and just kill it.

    So what is in this scrollview? Is it something really big?

  • Thank you for the information @AdamP but the page has a grid which contains 2 rows one row contains admob control and the other contains this scrollview with label inside it. Yes I have large text in it. just to give you an idea of data inside the label, the label contains the text in the below link. Do you think label is taking that much memory ?

    http://sanskritdocuments.org/doc_devii/mahaalaxmisahasra.html?lang=te

  • Hi @AdamP could you please tell me how to load large text in label

  • Someone please help me, is there an issue with large text in the label ? Maybe I need to used different control ? please suggest this is a show stopper for me.

  • Hi @JesseLiberty could you please help me with this.

  • Hi @MaxMeng Thank you for pointing it, I saw that earlier.
    but in xamarin forms

    A Label is used to display single-line text elements as well as multi-line blocks of text.

    It's working fine in remaining 2 platforms. for uitextview I need to use editor control which is not meant for reading like a book. But I will give it a try, Also is there any other way to display large text like book ? Please tell me.

  • JohnHardmanJohnHardman GBUniversity mod

    @ManikantaPratapVarma - another option is to load the text (which is around 27KB in size) into a WebView when using Xamarin.Forms. I use WebViews in this way for displaying my Terms & Conditions, License Agreement, and Privacy Policy. Those are about half the size of your text, but I would expect 27KB to be easily handled by a WebView.

  • MOFADevsMOFADevs QAUniversity ✭✭

    @AdamP
    I have exact similar problem. HockeyApp shows the following when the app creashes:
    Xamarin.Forms.Grid.MeasuredStarredColumns()<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Grid.MeasureAndContractStarredColumns(double width, double height, double totalStarsWidth)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Grid.MeasureGrid(double width, double height, bool requestSize)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Grid.OnSizeRequest(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.VisualElement.OnMeasure(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.VisualElement.GetSizeRequest(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Layout.GetSizeRequest(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.VisualElement.Measure(double widthConstraint, double heightConstraint, MeasureFlags flags)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.StackLayout.CalculateNaiveLayout(StackLayout.LayoutInformation layout, StackOrientation orientation, double x, double y, double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.StackLayout.CalculateLayout(StackLayout.LayoutInformation layout, double x, double y, double widthConstraint, double heightConstraint, bool processExpanders)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.StackLayout.OnSizeRequest(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.VisualElement.OnMeasure(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.VisualElement.GetSizeRequest(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Layout.GetSizeRequest(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.VisualElement.Measure(double widthConstraint, double heightConstraint, MeasureFlags flags)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Grid.MeasuredStarredColumns()<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Grid.MeasureAndContractStarredColumns(double width, double height, double totalStarsWidth)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Grid.MeasureGrid(double width, double height, bool requestSize)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Grid.OnSizeRequest(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.VisualElement.OnMeasure(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.VisualElement.GetSizeRequest(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Layout.GetSizeRequest(double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.VisualElement.Measure(double widthConstraint, double heightConstraint, MeasureFlags flags)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.StackLayout.CalculateNaiveLayout(StackLayout.LayoutInformation layout, StackOrientation orientation, double x, double y, double widthConstraint, double heightConstraint)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.StackLayout.CalculateLayout(StackLayout.LayoutInformation layout, double x, double y, double widthConstraint, double heightConstraint, bool processExpanders)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.StackLayout.LayoutChildren(double x, double y, double width, double height)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Layout.UpdateChildrenLayout()<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Layout.OnSizeAllocated(double width, double height)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.VisualElement.SizeAllocated(double width, double height)<e803df24fdc846ebae764c74c7975377>:0 Xamarin.Forms.Layout.<>c.<OnChildMeasureInvalidated>b__40_0()<e803df24fdc846ebae764c74c7975377>:0 Foundation.NSAsyncActionDispatcher.Apply()NSAction.cs:163 UIKit.UIApplication.UIApplicationMain(int, string[], intptr, intptr)(wrapper managed-to-native) UIKit.UIApplication.Main(string[] args, IntPtr principal, IntPtr delegate)UIApplication.cs:79 UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName)UIApplication.cs:63 MOFA.News.iOS.Application.Main(string[] args)

Sign In or Register to comment.