Eel icon indicating copy to clipboard operation
Eel copied to clipboard

Eel sometimes takes infinitely long to render a webpage

Open padfoot9445 opened this issue 2 years ago • 0 comments

Eel version 0.16.0

Describe the bug At seemingly random, eel never exits the loading page To Reproduce Steps to reproduce the behavior:

  1. create simple application using eel
  2. run it multiple times until the page fails to load

Expected behavior The page should have loaded properly every time System Information

  • OS: Microsoft Windows 11 Home System Type x64-based PC
  • Browser: chrome 116
  • Python Distribution: Python 3.11.5 (tags/v3.11.5:cce6ba9, Aug 24 2023, 14:38:34) [MSC v.1936 64 bit (AMD64)] on win32

Additional context as reccomended by https://github.com/python-eel/Eel/issues/393, i added the print statement. Every file parses even when it doesnt load properly.

import chess
import eel

board = chess.Board()
print("Initialised")
@eel.expose
def _validate_move(source, destination, piece) -> bool:
    if not (board.turn == chess.WHITE and piece[0] == "w" or board.turn == chess.BLACK and piece[0] == "b") or source == destination:
        return False
    if chess.Move.from_uci(f"{source}{destination}") in board.legal_moves:
        board.push(chess.Move.from_uci(f"{source}{destination}"))
        print(board.fen())
        return True
    else:
        return False
                                       
    print("F")
eel.init(r"D:\coding\Python\chess\opening_trainer\eel_app\web")
eel.start("main.html",disable_cache=True)
print("G")
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="css/chessboard-1.0.0.min.css">
        <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
        <script src="js/chessboard-1.0.0.min.js"></script>
        <script src="mainjs.js" defer></script>
        <script type="text/javascript" src="/eel.js"></script>
        <link rel="stylesheet" href="main.css"></linkt>
        
        
        
    </head>
    <body>
        <div id="main-container" class="main-horizongal-flex">
            <div id="board-and-pgn-container">
                <div id="board" style="width: 400px"></div>
                <div id="pgn">PGN HERE</div>
            </div>
            <div id="moves-container">
                <ul id="moves" class="moves-options">
                    <li>Move 1</li>
                    <li>Move 2</li>
                </ul>
            </div>
        </div>
    </body>
</html>

let config = {
    draggable: true,
    position: 'start',
    onDrop: onDrop
  }
  


let board = ChessBoard("board", config);
function move(source, target, piece, newPos){
    board.position(newPos,false);
    if(piece=="wK"&&source=="e1"&&(target=="g1"||target=="c1")){
        if(target=="g1"){
            board.move("h1-f1");
        } else{
            board.move("a1-d1");
        }
    } else if(piece=="bK"&&source=="e8"&&(target=="g8"||target=="c8")){
        if(target=="g8"){
            board.move("h8-f8");
        } else{
            board.move("a8-d8");
        }
    }
}
async function moveIfValid(source, target, piece, newPos){
    await eel._validate_move(source, target, piece)(function(result){
                if(result==true){
                    move(source, target, piece,newPos);
                }
            })
}
function onDrop(source, target, piece, newPos, oldPos, orientation){
    moveIfValid(source, target,piece, newPos);
    return "snapback";
}

padfoot9445 avatar Sep 23 '23 11:09 padfoot9445