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.

run_on_ui_thread crash

See original GitHub issue

error output:

AttributeError : 'Wv' object has no attribute 'f2'

runable.py

def run_on_ui_thread(f):
    '''Decorator to create automatically a :class:`Runnable` object with the
    function. The function will be delayed and call into the Activity thread.
    '''
    def f2(*args, **kwargs):
        Runnable(f)(*args, **kwargs)
    return f2

python : 3.7.1 cyrhon: 0.28.6 Kivy: 1.10

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
onodnawijcommented, May 10, 2020

Having the same problem. Solved by not using the decorator and just using a function.

def run_ui_thread(f, *args, **kwargs):
    # args/kwargs to runnable was a bug, fixed in master
    Runnable(f)(args, kwargs)

i know this issue is closed and its been a while, but could you please post your whole code on the solution? been tryng to implement it without success. thanks!

Another solution is putting create_webview function outside the class. Because it likely trying to find the ‘f2’ inside Wv class.

from kivy.app import App
from jnius import autoclass
from kivy.clock import Clock
from android.runnable import run_on_ui_thread
from kivy.uix.widget import Widget

WebView = autoclass('android.webkit.WebView')
WebViewClient = autoclass('android.webkit.WebViewClient')
activity = autoclass('org.kivy.android.PythonActivity').mActivity

@run_on_ui_thread
def create_webview(*args):
	webview = WebView(activity)
	webview.getSettings().setJavaScriptEnabled(True)
	wvc = WebViewClient();
	webview.setWebViewClient(wvc);
	activity.setContentView(webview)
	webview.loadUrl('https://google.com')


class Wv(Widget):
	def __init__(self, **kwargs):
		super().__init__(**kwargs)
		self.__functionstable__ = {}
		Clock.schedule_once(create_webview, 0)
	

class ServiceApp(App):
	def build(self):
		return Wv()
0reactions
5developercommented, Oct 16, 2020

whithout using decorator

Read more comments on GitHub >

github_iconTop Results From Across the Web

runOnUiThread crash when calling in asyntask - Stack Overflow
im using runOnUiThread to show UI fromasyntask but my app is crash please help me what do i do? how do i showmy...
Read more >
runOnUiThread Crash - C++ - Cocos Forums
Hi, I want to call the java method from c++ level, so I use jni way by JNIHelper. In my Java class, there...
Read more >
app crashes (Example) | Treehouse Community
app crashes when i run it because of this line runOnUiThread(new Runnable() { @Override public void run() { mProgressBar.setVisibility(View.
Read more >
'void android.app.Activity.runOnUiThread(java.lang.Runnable ...
Found issue: Application crash in CordovaWebViewImpl.java runOnUiThread #884 but this was closed due to lack of information
Read more >
Activity | Android Developers
If a child activity fails for any reason (such as crashing), the parent activity will receive a result ... public final void runOnUiThread...
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