Repository: stable-diffusion-webui
Issue: [Bug]: /v1/progress crashes with NaN. Please Fix.
Labels: bug-report

### Is there an existing issue for this?

- [X] I have searched the existing issues and checked the recent builds/commits

### What happened?

*** API error: GET: http://127.0.0.1:7860/sdapi/v1/progress {'error': 'TypeError', 'detail': '', 'body': '', 'errors': "unsupported operand type(s) for -: 'float' and 'NoneType'"}
    Traceback (most recent call last):
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 98, in receive
        return self.receive_nowait()
               ^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 93, in receive_nowait
        raise WouldBlock
    anyio.WouldBlock

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 78, in call_next
        message = await recv_stream.receive()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 118, in receive
        raise EndOfStream
    anyio.EndOfStream

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\stable-diffusion\modules\api\api.py", line 187, in exception_handling
        return await call_next(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 84, in call_next
        raise app_exc
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 70, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 108, in __call__
        response = await self.dispatch_func(request, call_next)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\modules\api\api.py", line 151, in log_and_time
        res: Response = await call_next(req)
                        ^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 84, in call_next
        raise app_exc
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 70, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\cors.py", line 84, in __call__
        await self.app(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\gzip.py", line 24, in __call__
        await responder(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\gzip.py", line 44, in __call__
        await self.app(scope, receive, self.send_with_gzip)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
        raise exc
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
        await self.app(scope, receive, sender)
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
        raise e
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
        await self.app(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 718, in __call__
        await route.handle(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 276, in handle
        await self.app(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 66, in app
        response = await func(request)
                   ^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\routing.py", line 237, in app
        raw_response = await run_endpoint_function(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\routing.py", line 165, in run_endpoint_function
        return await run_in_threadpool(dependant.call, **values)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\concurrency.py", line 41, in run_in_threadpool
        return await anyio.to_thread.run_sync(func, *args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\to_thread.py", line 33, in run_sync
        return await get_asynclib().run_sync_in_worker_thread(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
        return await future
               ^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
        result = context.run(func, *args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\modules\api\api.py", line 505, in progressapi
        time_since_start = time.time() - shared.state.time_start
                           ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
    TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'

### Steps to reproduce the problem

1. Call /progress


### What should have happened?

Shouldnt crash. Crashes the whole a1111

### Sysinfo

latest.

### What browsers do you use to access the UI ?

_No response_

### Console logs

```Shell
*** API error: GET: http://127.0.0.1:7860/sdapi/v1/progress {'error': 'TypeError', 'detail': '', 'body': '', 'errors': "unsupported operand type(s) for -: 'float' and 'NoneType'"}
    Traceback (most recent call last):
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 98, in receive
        return self.receive_nowait()
               ^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 93, in receive_nowait
        raise WouldBlock
    anyio.WouldBlock

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 78, in call_next
        message = await recv_stream.receive()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\streams\memory.py", line 118, in receive
        raise EndOfStream
    anyio.EndOfStream

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\stable-diffusion\modules\api\api.py", line 187, in exception_handling
        return await call_next(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 84, in call_next
        raise app_exc
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 70, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 108, in __call__
        response = await self.dispatch_func(request, call_next)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\modules\api\api.py", line 151, in log_and_time
        res: Response = await call_next(req)
                        ^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 84, in call_next
        raise app_exc
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\base.py", line 70, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\cors.py", line 84, in __call__
        await self.app(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\gzip.py", line 24, in __call__
        await responder(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\gzip.py", line 44, in __call__
        await self.app(scope, receive, self.send_with_gzip)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
        raise exc
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
        await self.app(scope, receive, sender)
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
        raise e
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
        await self.app(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 718, in __call__
        await route.handle(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 276, in handle
        await self.app(scope, receive, send)
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\routing.py", line 66, in app
        response = await func(request)
                   ^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\routing.py", line 237, in app
        raw_response = await run_endpoint_function(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\fastapi\routing.py", line 165, in run_endpoint_function
        return await run_in_threadpool(dependant.call, **values)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\starlette\concurrency.py", line 41, in run_in_threadpool
        return await anyio.to_thread.run_sync(func, *args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\to_thread.py", line 33, in run_sync
        return await get_asynclib().run_sync_in_worker_thread(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
        return await future
               ^^^^^^^^^^^^
      File "C:\stable-diffusion\venv\Lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
        result = context.run(func, *args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\stable-diffusion\modules\api\api.py", line 505, in progressapi
        time_since_start = time.time() - shared.state.time_start
                           ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
    TypeError: unsupported operand type(s) for -: 'float' and 'NoneType'
```


### Additional information

_No response_