Bug: EdgeChromium - state sometimes getting stuck
Hello,
I tried using the new state feature but sometimes the program execution gets stuck. After some investigation, I found that the issue comes from "edgechromium.py" specifically in the "evalutate_js" function.
For some reason, "self.webview.ExecuteScriptAsync(script)" occasionally doesn’t return anything, which means the "_callback" function is never called and the semaphore is never released.
I patched it by initializing the semaphore with "Semaphore(1)" instead of "Semaphore(0)". It seems to work but I'm not sure if this is a good solution.
Have you ever encounter this problem ?
Did you resolve this problem? If not, could you provide a minimal example demonstrating the bug?
Hello, I created a small project that reproduces the bug. You can find it here https://github.com/jeanbaptiste444/pywebview-state-bug-example.git.
Build:
python -m venv env
pip install -e .
python main.py
Explaination: On the home page of this example, when you click the button, a POST form is sent to "/".
def index(self):
if request.method == "POST":
for i in range(10):
print("a")
self.window.state.progress = f"{i}/10"
print("b")
return render_template("index.html")
I added print("a") before and print("b") after state update in the loop. After clicking the button, when you look at the console, only 'a' is printed and the program execution gets stucked on the state update.
I don't know if this helps, but there is no problem when the post request is made from Javascript. I added a second button in my example that shows this.
The problem is in your code. When you submit the form, it results in a page refresh, which resets everything