Languages

Menu
Sites
Language
ewk_view_script_execute works from a button, not from a thread. Does it need "Main thread" access? If yes, how?

My simple app has to run a small JS in a Web View. It works when calling it from a button but it doesn't work when ran from a thread. Does the Web View require to be accessed in something like a main loop? I cannot find anything on this in C. I need to run in main thread/ UI thread in iOS but I cannot find any information on this for Tizen.

 

 

static void

create_base_gui(appdata_s *ad)

{

    pthread_t tid;

    pthread_create(&tid, NULL, &checker, NULL);

}
 

void scriptCallback(Evas_Object* o, const char* result_value, void* user_data) {

    dlog_print(DLOG_DEBUG, "AAAMYTAG", "scriptCallback %s", result_value);

}

 

void *checker(void *arg)

{

    while(true)

    {

        COUNTER++;

        runJS();

        sleep(5);

    }

    return 0;

}

 

void runJS() {

 

     const char scripts[]="function test() { return 'test'; }; test();";

        void (*cb_test)(Evas_Object*, const char*, void*) = scriptCallback;

        ewk_view_script_execute(amg->web_view, scripts, cb_test, NULL); //doesnt do anything

}

 

static void

btn_prev_cb(void *data, Evas_Object *obj, void *event_info){

 

    const char scripts[]="function test() { return 'test'; }; test();";

    void (*cb_test)(Evas_Object*, const char*, void*) = scriptCallback;

    ewk_view_script_execute(amg->web_view, scripts, cb_test, NULL); //works perfectly fine

}

 

 

 

 

Thank you

 

 


 

 

 

Responses

1 Replies
Paul L

Hello, you have to modify ui components from the main thread. Check this link: https://www.enlightenment.org/develop/legacy/program_guide/threading/thread_use_example