Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity UI freezes using iOS 8

Discussion in 'iOS and tvOS' started by jdtogni, Oct 14, 2014.

  1. jdtogni

    jdtogni

    Joined:
    Sep 25, 2013
    Posts:
    1
    Hi all,

    I have a native iOS plugin in which I present a modal view.
    Once closed, it randomly causes the unity UI to freeze - sounds and interactions are still going on, but the UI does not redraw.

    I narrowed down to a simple test where the native code is quite simple, but I still see freezes.
    My only finding so far is that removing iOS animations makes it harder to reproduce.

    In this code, its easier to reproduce while typing on the webview keyboard.
    - Tested on iPhone 5, 6, 6+, fails on all of them, seems to work on iPads...
    - Tried with a button to close the UI

    Here is the native code that causes the issue:
    void _openUI() {
    // present a view controller with a webview, and load www.google.com
    UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
    UIViewController *vc = [[UIViewController alloc] init];
    UIWebView *wv = vc.view = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,300,300)];
    [wv loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:mad:"http://www.google.com"]]];

    [rootViewController presentViewController:vc animated:YES completion:^{
    NSLog(@"presented"); // called once animations are finished.
    // auto-close in 2 sec. I also tried separate function + close button and it still freezes.
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    NSLog(@"dismiss");
    [wv stopLoading]; // no need to set delegates, lets just stop the webview
    [vc dismissViewControllerAnimated:YES completion:^{
    NSLog(@"dismissed"); // called once animations are finished
    }];
    });
    }];
    }

    The C# portion is pretty standard, just declares this openUI function.

    Any ideas?
    Is there any Unity function I could try run to un-freeze the UI?

    Regards,
    Daniel
     
  2. Aithoneku

    Aithoneku

    Joined:
    Dec 16, 2013
    Posts:
    67
    Happens to me, too;
    - unity scene is running
    - open a web view (UIWebView)
    - close it
    - unity scene is frozen, but reacts on touches

    Notes:
    - happens with iOS 8, didn't happen in previous versions
    - iPad 4
    - I apologize, but I cannot provide code
     
  3. Aithoneku

    Aithoneku

    Joined:
    Dec 16, 2013
    Posts:
    67
    So, I maybe found a hack to this: recreate GL surface after the web view is closed (it's not needed to wait until the animation finishes or anything). However, because I don't know what is real reason of the freeze, I wouldn't consider this as real fix.
     
  4. sparky222b

    sparky222b

    Joined:
    Feb 28, 2013
    Posts:
    2
    Seeing the same behavior; has anyone filed or thought about filing an issue report?

    @Aithoneku could you elaborate on your workaround?
     
  5. Aithoneku

    Aithoneku

    Joined:
    Dec 16, 2013
    Posts:
    67
    I didn't fill it.

    Problem with me is that my knowledge of iOS and Apple devices in general are very low (I worked with itonly one week or so), and the project I was working on (not any more) is not mine, so I'm unable to create simple example for bug report. I'm sorry for that.

    About the workaround: the OpenGL buffers are created with glGenRenderbuffersOES in our project. The workaround is to destroy them and create again. (Context is kept so no need to recreate all GL objects like textures.) Is that better?
     
  6. fluxrad

    fluxrad

    Joined:
    Nov 10, 2014
    Posts:
    2
    Did you ever find a function to run to fix this?
     
  7. inewland

    inewland

    Joined:
    Dec 6, 2012
    Posts:
    20
    I had a similar issue with a custom plugin I wrote. It turned out to be something with the native keyboard. I noticed the keyboard was restoring its previous state when pushing/popping view controllers in and out. I don't think it resigns properly. I had this problem on a search bar and had to call:

    Code (CSharp):
    1. - (void) viewWillDisappear:(BOOL)animated
    2. {
    3.     // searchBar = UISearchBar
    4.     [self.searchBar resignFirstResponder];
    5. }
    This ensured that the keyboard was always dismissing properly. Cleared up the UI locking/freezing issue for me.

    iOS 8, iPad Air
     
  8. Hoskins355

    Hoskins355

    Joined:
    Jan 3, 2013
    Posts:
    142
    I am also having this issue any suggestions anyone? For me I am returning from iYouTube plugin and gui freezes. I think it is also a UIViewController problem.
     
  9. mog-mog-mog

    mog-mog-mog

    Joined:
    Feb 12, 2014
    Posts:
    266
    Ditto, I am seeing this issue on ipad where game UI freezes but buttons-game is actually working fine in background. If user rotate the screen mode to landscape/portrait (assuming device is not locked - it works fine. Is there any bug for this?
    I see this issue once in a while on my ipad late 2012 model when importing texture from gallery/camera using IOSNative plugin. Is there any fix?
     
  10. Hoskins355

    Hoskins355

    Joined:
    Jan 3, 2013
    Posts:
    142
    I think it has to do with the UIViewController not closing properly and giving the view back to GUI. Find in the code where the UIViewController is closed, and you can try to wait 0.5 sec then run
    dismissModalViewControllerAnimated:YES. From what I have read I think that will work, but for me this was in a .dll or maybe in a jar file but I was unable to find it and got no help from the maker of the plugin.
     
  11. mylastgg

    mylastgg

    Joined:
    Jun 1, 2013
    Posts:
    2
    Hi guys, sorry to bump this.

    Actually, I'm not a Unity developer, I come from cocos2d-x.
    I've experienced the same issue you are describing on cocos2d-x 3.4: a UIWebView was causing the GL rendering to freeze, even if the game was still playable if I smashed the screen randomly.

    I had 3 UIView with one WebView each. I experienced the problem just on one of these WebViews.
    The only difference between the bugged one and the others was that the bugged one had a translucent navigation bar while the others didn't.
    The moment I turned Translucent off from Storyboard, everything started to work flawlessly (so far).

    I know it might seems strange or not work for you, but I just wanted to share what I found!

    Hope this helps : )
     
  12. Aithoneku

    Aithoneku

    Joined:
    Dec 16, 2013
    Posts:
    67
    Note: I'm sorry, I can't confirm whether it helps me or not, because I have no longer access to the project so I can't be any help now.