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

[no squash] Get rid of the last remaining sync. HTTP requests on the main thread #14649

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

grorp
Copy link
Member

@grorp grorp commented May 13, 2024

Building upon the work in #13551 and #14412, this PR aims to make sure that there will never be ANRs related to HTTP requests again.

  • Commit 1 moves the last remaining HTTP request from the main thread to core.handle_async. To reduce the amount of changes to existing code and to avoid callback hell, it uses coroutines.

    The HTTP request in question is the one that fetches a dependency list from CDB before attempting to install a package. While it's usually very fast, it can take long if you have a bad internet connection or if it times out.

  • Commit 2 removes the ability to execute synchronous HTTP requests on the main thread from httpfetch.cpp. This doesn't break backwards compatibility because fetch_sync is only available in the mainmenu. Since any synchronous HTTP request on the main thread is a bug, we should avoid introducing one again in the future.

To do

This PR is a Ready for Review.

  • Investigate whether more code can be removed from httpfetch.cpp.
    There is probably more to remove, but I fear that I don't know the code well enough to avoid accidentally breaking things.

How to test

Verify that Minetest doesn't freeze for a short while anymore after you press the install button on a package.

Try to install lots of different packages from CDB. Verify that dependencies are resolved correctly and that packages are installed correctly.

@grorp grorp force-pushed the no-sync-http-main-thread branch 4 times, most recently from b13197b to d89cd5b Compare May 14, 2024 13:32
@grorp grorp added this to the 5.9.0 milestone May 21, 2024
grorp added 2 commits May 29, 2024 16:18
Any sync. HTTP request on the main thread is a bug, don't allow introducing one again.
@grorp grorp force-pushed the no-sync-http-main-thread branch from d89cd5b to 6245073 Compare May 29, 2024 14:18
@sfan5 sfan5 requested a review from rubenwardy May 31, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants