Skip to content

Commit

Permalink
removed hardcoded sleep (#4713)
Browse files Browse the repository at this point in the history
  • Loading branch information
CrackedPixel authored Jan 20, 2025
1 parent 773e3f5 commit 77c509d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/platforms/rcore_web.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,15 @@ static const char *GetCanvasId(void);
//----------------------------------------------------------------------------------

// Check if application should close
// This will always return false on a web-build as web builds have no control over this functionality
// Sleep is handled in EndDrawing for sync code
bool WindowShouldClose(void)
{
// Emterpreter-Async required to run sync code
// https://github.com/emscripten-core/emscripten/wiki/Emterpreter#emterpreter-async-run-synchronous-code
// By default, this function is never called on a web-ready raylib example because we encapsulate
// frame code in a UpdateDrawFrame() function, to allow browser manage execution asynchronously
// but now emscripten allows sync code to be executed in an interpreted way, using emterpreter!
emscripten_sleep(16);
// This function should not called on a web-ready raylib build because you instead want to encapsulate
// frame code in an UpdateDrawFrame() function, to allow the browser to manage execution asynchronously
// using emscripten_set_main_loop
return false;
}

Expand Down

2 comments on commit 77c509d

@raysan5
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CrackedPixel Was this change properly tested? Because I received reports of Linux users with broken Web builds because of it and it also broke all my ASYNCIFY tools on Windows... I'm reverting it.

@zet23t
Copy link
Contributor

@zet23t zet23t commented on 77c509d Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also caused hanging websites in Firefox on Windows.

Please sign in to comment.