Search Unity

[Workaround] ios7: DisplayLink + Scrolling results in crash

Discussion in 'iOS and tvOS' started by Alexey, Oct 3, 2013.

  1. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    if on ios7 your app crashes inside DisplayLink
    with callstack having
    Code (csharp):
    1. QuartzCore`CA::Display::DisplayLinkItem::dispatch()
    2. ...
    3. IOMobileFramebuffer`IOMobileFramebufferVsyncNotify
    when you have some scrolling going on (be it table view, or keyboard scrolling for japaneese language, or your own scroll view)
    here is a workaround.
    in UnityAppController.mm look for repaintDisplayLink method, and comment out code like that:

    Code (csharp):
    1. - (void)repaintDisplayLink
    2. {
    3. /*
    4.     [_displayLink setPaused: YES];
    5.     {
    6.         static const CFStringRef kTrackingRunLoopMode = CFStringRef(UITrackingRunLoopMode);
    7.         while (CFRunLoopRunInMode(kTrackingRunLoopMode, kInputProcessingTime, TRUE) == kCFRunLoopRunHandledSource)
    8.             ;
    9.     }
    10.     [_displayLink setPaused: NO];
    11. */
    12.     if(_didResignActive)
    13.         return;
    14.  
    15.     SetupUnityDefaultFBO(_mainDisplay->surface);
    16. ....
    17. }
    18.  
     
  2. JFo

    JFo

    Joined:
    Dec 9, 2007
    Posts:
    217
    Thank you Alexey!
    I've been looking for solution to this crash since yesterday! It seems that the workaround fixed it...

    BR,
    Juha
     
  3. h264

    h264

    Joined:
    Oct 8, 2013
    Posts:
    3
    Thanks for offering the solution, Alexey! It's been a real witch hunt after this very strange crash. Before I'll start updating my apps, what are the side effects for your fix? Will that affect touch event processing?
     
  4. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    from my understanding (and some internal testing) there are no sideffects completely.
    It was needed long ago when unity was run in default run loop, so we needed to give some time to other runloops (tracking, for touches/scrolling etc)
    but then at some point we moved unity playr loop to be scheduled in "common" run loop (read: now it should be scheduled along with all events/messages/etc), so this is more or less just a leftover.
     
  5. h264

    h264

    Joined:
    Oct 8, 2013
    Posts:
    3
    That's great! Thanks for confirming so quickly, Alexey
     
  6. MattPicioccio

    MattPicioccio

    Joined:
    Aug 26, 2013
    Posts:
    1
    Alexey,

    We use an automated build system to generate our XCode projects, and we are running into this crash. How can we fix UnityAppController.mm in this way?

    Assets/Plugins/iOS code goes to Library, and if we put a duplicate of UnityAppController.mm in that folder, we (correctly) get errors about duplicated classes (as the real one is in Classes).

    I tried subclassing and overriding repaintDisplayLink, but the rest of that functionality refers to private members and methods. I can't call "super" without running into the original problem, and I can't expose the private members and methods - if I could, I just would make the change directly.
     
  7. FatWednesday

    FatWednesday

    Joined:
    Jul 4, 2012
    Posts:
    50
    Been trying to find the cause of this crash for a while now, it always seems to be very random and difficult for us to re-create in our testing (seems to trigger when we launch native dialogs but not all the time).

    Testing out this workaround at the moment to see if it seems to solve the issue.

    Is this a bug within unity? and if so has a bug report been made? Or are we all just missing something when opening dialogs or other native things over unity?

    UPDATE 1:
    This workaround has not worked for us, I'm still seeing the crash (currently testing on iOS6.2 on an iPad3). Does anyone else have any idea what is causing this / potential fixes?



    UPDATE 2:
    It actually seems like this workaround made the issue worse in our case. Before I was noticing the crash occasionally when launching the app, now however with the workaround It crashes without fail every time we launch.
     
    Last edited: Nov 13, 2013
  8. FatWednesday

    FatWednesday

    Joined:
    Jul 4, 2012
    Posts:
    50
    @MattPicioccio

    If you're using Automated build systems, your best bet is probably using PostprocessBuildPlayer scripts to modify the XCode project after its built. You should be able to write a script that just grabs the UnityAppController.mm searches for the relevant code and comments it out.
     
  9. gecko938

    gecko938

    Joined:
    Dec 28, 2011
    Posts:
    12
  10. aikitect

    aikitect

    Joined:
    Dec 28, 2012
    Posts:
    28
    Would also love to know if this is the case.
     
  11. Rubilei

    Rubilei

    Joined:
    Dec 9, 2013
    Posts:
    1
    You saved my job , Thanks!!!!!!!