App crash on iOS

Hi,

I’ve got a little playground that I’ve been using to play around with Fuse for the past couple of days. I installed a version of the app on my iPhone 6 running iOS 10 (developing on OS X El Capitan). Simple app - it’s just a single view in a Navigator with an Each iterating over results from an API call. I noticed that every now and then, when I try to open the app on my phone, it would immediately crash. The splash screen would come up for a split-second and it would crash. It would do this repeatedly (like 6, 7, times), but then on the next attempt it would open just fine. Once it opened fine, it would be fine for a while.

At first, I thought it was some bad JS running when the page was activated, so I turned that off and deployed a new version of the app. When my phone got into this situation, both the original app and the new one would crash immediately after trying to open it.

Next, I suspected maybe the fonts being loaded were causing it to crash, so I removed the fonts and deployed a third app to my phone. But for the past day or so, I can’t even get the original app to crash upon load. All three versions run just fine.

I can provide a stripped-down version of the code if that would do any good, but the API that’s called is internal only, so it wouldn’t be functioning. Instead, I captured this crash log from iOS that hopefully will be helpful.

Relevant snippet:

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001871644f8
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [0]
Triggered by Thread:  0

Application Specific Information:
BUG IN CLIENT OF LIBDISPATCH: trying to lock recursively

Two other things that might be of interest/related.

(1)
I notice that when I launch the app, there is a slight delay between the time I tap the icon and the time that the splash screen appears. Like up to 5 seconds sometimes, but very inconsistent.

(2)
When I launch the app while connected to my laptop (set up to break on exceptions), I get an exception thrown at in file Fuse.Storage.g.cpp:

// public static string Read(string filename) [static] :32
uString* ApplicationDir::Read(uString* filename)
{
    if (::g::Uno::String::op_Equality(filename, NULL))
        U_THROW(::g::Uno::ArgumentNullException::New6(::STRINGS[0/*"filename"*/]));

    uString* filepath = ::g::Uno::IO::Path::Combine(::g::Uno::IO::Directory::GetUserDirectory(1), filename);

    if (::g::Uno::IO::File::Exists(filepath))
        return ::g::Uno::IO::File::ReadAllText(filepath);
    else
        U_THROW(::g::Uno::Exception::New2(::STRINGS[1/*"File does n...*/]));  <-- EXCEPTION HERE
}

The file that it’s looking for, that doesn’t exist, is: /var/mobile/Containers/Application/[some-id]/Documents/FuseLocalStorage/

I don’t think that’s related to the crash because even when that error comes up (i.e. every time), the app resumes once I play through the breakpoint.

Again, happy to submit the full source of my app, but I’d have to modify it and the repro is not consistent anyway. The gist of the app is as follows:

fuse-playground.unoproj:

{
  "RootNamespace":"",
  "Packages": [
    "Fuse",
    "FuseJS",
    "FuseCore",
    "UnoCore",
    "Fuse.Triggers",
    "Fuse.Navigation",
    "Fuse.iOS"
  ],
  "Includes": [
    "*",
    "Assets/Images/anon_avatar.png:Bundle",
    "scripts/queries/*.js:Bundle",
    "scripts/configs/*.js:Bundle",
    "bower_components/moment/moment.js:Bundle"
  ],
  "iOS": {
    "LaunchImages": {
      "iPhone_Portrait_2x": "Assets/Images/splash/Default@2x~iphone.png",
      "iPhone_Portrait_R4": "Assets/Images/splash/Default-568h@2x~iphone.png",
      "iPhone_Portrait_R47": "Assets/Images/splash/Default-667h.png",
      "iPad_Portrait_1x": "Assets/Images/splash/Default-Portrait~ipad.png",
      "iPad_Portrait_2x": "Assets/Images/splash/Default-Portrait@2x~ipad.png",
      "iPad_Landscape_1x": "Assets/Images/splash/Default-Landscape~ipad.png",
      "iPad_Landscape_2x": "Assets/Images/splash/Default-Landscape@2x~ipad.png"
    }
  }
}

Main.ux:

<App>
  <Router ux:Name="router" />

  <Viewport Perspective="1000">
    <Panel>
      <Navigator DefaultTemplate="activeUsers">
        <ActiveUsers ux:Template="activeUsers" router="router" />
      </Navigator>
    </Panel>
  </Viewport>
</App>

Note: The use of Viewport was going to my next A/B test, but I can’t get it to crash anyway. I’ll update on whether that has any bearing on the load times, though.

ActiveUsers.ux:

<Page ux:Class="ActiveUsers">
  <Router ux:Dependency="router" />

  <JavaScript File="ActiveUsers.js" />

  <DockPanel>
    <StackPanel Dock="Top" Background="#ff674c">
      <StatusBarBackground Dock="Top"/>
      <Fuse.iOS.StatusBarConfig Style="Light" IsVisible="True" Animation="Slide" />
      <Panel>
        <Text Value="Active Users" TextAlignment="Center" TextColor="#fff" FontSize="24" Margin="0,10,0,5" />
      </Panel>
    </StackPanel>
    <ScrollView SnapMinTransform="false">
      <DockPanel>
        <CogWheelReload Dock="Top" /> <!-- taken straight from the pull-to-reload example --> 
        <StackPanel>
          <Text Value="{lastUpdatedObs}" FontSize="10" Alignment="Center" Margin="5" Color="#000" />
          <Each Items="{users}">
            <Deferred>
              <!-- another dock panel with east list item contents -->
            </Deferred>
          </Each>
        </StackPanel>
      </DockPanel>
    </ScrollView>
  </DockPanel>
</Page>

Just a quick update regarding the Viewport removal. I’ve removed it, but there’s still an inconsistent 3-5 second delay before the launch image/splash screen sometimes.

Sorry for the poorly articulated question. There’s a lot going on so let me try to distill.

(1) I’m going to split out the app launch delay issue into a different forum post.
(2) I think the exception produced from Fuse.Storage.g.cpp is a non-issue (at least not relating to the crash), so no action needed on that.

As for the crash, I made some progress trying to home in on the root cause last night. I strongly suspect font-loading to be the cause. I produced two apps:

(1) Pretty simple bare-bones app:

(2) Same app but with some fonts being loaded:

Only code differences are:

In MainView.ux:

<App>
  <Router ux:Name="router" />
  <Fuse.iOS.StatusBarConfig ux:Name="statusBarConfig" Style="Dark" Animation="Slide" />

  <!-- Added these lines -->
  <Font File="Assets/Fonts/Akkurat-Bold.otf" ux:Global="Bold" />
  <Font File="Assets/Fonts/Akkurat.otf" ux:Global="Regular" />
  <Font File="Assets/Fonts/Akkurat-Light.otf" ux:Global="Light" /> 
  <!-- End of added lines -->

  <Panel>
    <Navigator DefaultTemplate="page1">
      <Page1 ux:Template="page1" router="router" sbc="statusBarConfig" />
      <Page2 ux:Template="page2" router="router" sbc="statusBarConfig" />
    </Navigator>
  </Panel>
</App>

And on Page1.ux:

<Text Value="Active Users" TextAlignment="Center" TextColor="#fff" FontSize="24" Margin="0,10,0,5" />

became:

<Text Font="Bold" Value="Active Users" TextAlignment="Center" TextColor="#fff" FontSize="24" Margin="0,10,0,5" />

This morning, I was able to get the 2nd app (w/ fonts) to repeatedly crash (not 100% of the time, but when it start crashing, it keeps on crashing). When the 2nd app is crashing repeatedly, the 1st app (no fonts) loads just fine.

Error message in crash logs is the same as before:

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001871644f8
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [0]
Triggered by Thread:  0

Application Specific Information:
BUG IN CLIENT OF LIBDISPATCH: trying to lock recursively

Hope this helps provide some clarity.

Hi, thanks for the excellent bug report. :slight_smile:

I will check out your example now, and see if I can trigger the problem.

Unfortunately I’m having a bit of trouble reproducing the problem you’re facing.

Have you noticed any special pattern as to when the app will crash yet? Should I repeatedly open and close the app, or is there something else I can do?

Also, is it possible for you to test the app on some other iOS device, to see if you are able to reproduce this on different devices?

I will look more into the problem and the stacktrace tomorrow, and keep you updated. :slight_smile:

Thanks for looking into this. I’m not surprised you’re having trouble reproducing. There was a full day that I didn’t get the crash (and I was obsessively opening the app every 15/30 minutes). Then the next day I got it very consistently.

I haven’t noticed any pattern as to when it happens. Except that when it crashes, it will repeatedly crash for a few minutes and then work just fine again.

I’ll install on another iOS device and let you know if it crashes there too.

I just found out we actually had some other problems related to font loading.

Some of those problems disappeared when upgrading to the latest Xcode. So if you don’t already have the latest Xcode version upgrading might fix the crash.

I understand this workaround is not ideal, and hopefully we can also figure out the root cause of this problem.

Karsten -

I’ve been using the latest XCode (Version 8.0 (8A218a)) for the duration of this project.

My workaround in the meanwhile is to not load any external fonts, but that’s not really tenable for the long term. Hopefully we can find the root cause/fix. I’d meant to install the app on another phone to try to reproduce, but haven’t had a chance yet. Will update you with the results when I do.

Thanks!

Hey Atish,

Did you experience the crash on any other devices? I have a very similar setup (El Capitan, Xcode 8, iOS 10), with the difference that I’m testing on an iPhone 5C. I’ve also not been able to reproduce the issue yet, neither in release or debug mode.

Any clues would be helpful. :slight_smile:

Cheers!

Hey, apparently since 0.26 I am also encountering a crash when building for ios release. preview on device works fine.
Checking the stack trace, it appears to be related to font loading.
0.27 is the same.
If anyone from the team is interested, ping me on slack (costin) and I can share the source code. The app is already on the app store (last version which worked), so it would be nice to have this fixed soon :slight_smile:

Thanks!

Costin: I haven’t fine-read the thread but if you have a new specific issue, please re-post that as a separate thread with a repro case. Your problem description here is a little too vague and off-topic to pick up on.

I’ve seen font loading mentioned above and I thought it was a similar issue.
Anyway, I’ve been trying to replicate it with no luck for the past few minutes. Could have been a .26 issue which took some time to clear in .27 (I did uno clean). Will keep you posted.

Hi!

This is indeed an issue with font loading on iOS. We have found a solution to the issue and a fix will be coming in a future release :slight_smile: Thanks for your patience!