question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spawning a UI Window from Plugin Method Causes Unpredictable results

See original GitHub issue

If you spawn a ViewController from a plugin on iOS, the following warning appears in the console: Main Thread Checker: UI API called on a background thread

And

[Animation] +[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior.

Which is certainly true. I’ve experienced weird rendering bugs, where certain things in a scene won’t render in the proper order - unpredictably each launch. Sometimes it works fine, sometimes labels will be moved under other elements.

I’ve tested this out by removing the dispatchQueue.async call here: https://github.com/ionic-team/capacitor/blob/master/ios/Capacitor/Capacitor/CAPBridge.swift#L385

With the Async wrapper removed, the UIView runs great.

It’d be nice if there was a way to tell Capacitor that I specifically want a method to run in the foreground because I’ll be launching UI elements to skirt around this whole issue.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
mlynchcommented, Oct 2, 2018

You need to execute any UI operations on the main thread, for example: https://github.com/ionic-team/capacitor/blob/master/ios/Capacitor/Capacitor/Plugins/Modals.swift#L20

    DispatchQueue.main.async {
      self.bridge.viewController.present(alert, animated: true, completion: nil)
    }
0reactions
ionitron-bot[bot]commented, Nov 11, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot form issues in model-driven apps - Microsoft Learn
The most common cause of intermittent or random form errors is using unsupported client API methods. These errors have the following ...
Read more >
Bug descriptions — spotbugs 4.7.3 documentation
To correctly override the compareTo() method in the Comparable interface, the parameter of compareTo() must have type java.lang.Object . Co: compareTo()/compare ...
Read more >
11 Methods How to Fix Window Explorer Keeps Crashing
Fix #7: Repair Corrupted System Files in your PC​​ Corrupted system files can cause the Windows Explorer search not responding issue. Check and...
Read more >
Uncaught SyntaxError: Unexpected token : - Stack Overflow
There was something causing problems with a standard Request call, so this is the code I used instead: vote.each(function(element){ element.
Read more >
IBM i Access - ACS Getting Started
IBM i Access Client Solutions - Windows Application Package ... if X were a shared network drive, the following setting may cause unpredictable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found