Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import_css blocks the main thread #296

Open
memecode opened this issue Feb 20, 2024 · 1 comment
Open

import_css blocks the main thread #296

memecode opened this issue Feb 20, 2024 · 1 comment
Labels

Comments

@memecode
Copy link

To implement the litehtml::document_container::import_css function:

void import_css(litehtml::string& text, const litehtml::string& url, litehtml::string& baseurl);

The application has to go out to the network and get the CSS and then at some later time, fill out 'text' with the content. That doesn't work if the network is slow to respond, taking seconds to complete...

A better way of doing it would be to pass a callback for the first parmeter... like:

void import_css(std::function<void(litehtml::string& text)> callback, const litehtml::string& url, litehtml::string& baseurl);

Then the implementor can go out setup a thread... pass the callback... do the network stuff... get the file... THEN call the callback. Maybe with some extra glue to make it run in the same thread as the caller.

litehtml just waits for the callback and applies the changes. No waiting around.

@tordex
Copy link
Member

tordex commented Feb 22, 2024

I agree with you. Right now I'm rewriting litebrowser-linux with multithreading support and found the css loading blocks. I'll try to solve this issue.

@tordex tordex added the ToDo label Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants