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

Endless black screen loading from large .img file when selfhosting, no issues manually loading on website #1089

Closed
HunterBoy344 opened this issue Jul 22, 2024 · 4 comments

Comments

@HunterBoy344
Copy link

HunterBoy344 commented Jul 22, 2024

My code:

<title>Basic Emulator</title><!-- not BASIC! -->

<style>
  html, body {margin: 0; height: 100%; width: 100%; overflow: hidden; background: black; position:relative; line-height: 1;}
  #screen_container {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: black;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  #vga {
    object-fit: contain;
    display: block;
    height: 100vh !important;
    width: auto !important;
    max-width: 100vw !important;
    border: solid 1px white;
  }
  * { margin:0; padding:0; }
</style>

<script src="libv86.js"></script>
<script>
"use strict";

window.onload = function()
{
    var emulator = window.emulator = new V86Starter({
        wasm_path: "v86.wasm",
        memory_size: 256 * 1024 * 1024,
        vga_memory_size: 8 * 1024 * 1024,
        screen_container: document.getElementById("screen_container"),
        bios: {
            url: "seabios.bin",
        },
        vga_bios: {
            url: "vgabios.bin",
        },
        hda: {
            url: "image.img",
            //async: true,
            //size: 3 * 1024 * 1024 * 1024,
        },
        acpi: false,
        network_relay_url: "wss://relay.widgetry.org/",
        autostart: true,
    });
    document.getElementById("screen_container").onclick = function()
    {
        emulator.lock_mouse();
    };
}
</script>

<!-- A minimal structure for the ScreenAdapter defined in browser/screen.js -->
<div id="screen_container" style="">
    <div id="screen"></div>
    <canvas id="vga"></canvas>
</div>

This results in an endless black screen. I'm hosting it with python3 -m http.server in the directory with all the files.

In the folder this runs from, there is an index.html, libv86.js, seabios.bin, vgabios.bin, v86.wasm, and of course image.img. The image file is 3 GB total. Uncommenting the lines about async does cause seabios to run, but the python webserver gives an error ending with ConnectionResetError: [Errno 104] Connection reset by peer and seabios says Boot failed: could not read the boot disk and fails to boot.

Notably, my problem is remarkably similar to this one, with the only difference being that he got this result with a large state file and I'm getting it with a large disk image.

@HunterBoy344 HunterBoy344 changed the title Loading from hard disk image doesn't work on embedded version Endless black screen loading from large .img file when selfhosting, no issues manually loading on website Jul 22, 2024
@SuperMaxusa
Copy link
Contributor

v86/docs/windows-xp.md

Lines 58 to 63 in 5435c2f

To open this HTML file locally, a HTTP server is needed. The standard Python server `python -m http.server` doesn't support HTTP range requests.
You can use [http-server](https://www.npmjs.com/package/http-server) or [devd](https://github.com/cortesi/devd).
Start the server (from the same folder as `winxp.htm`):
```
npx http-server
```

@HunterBoy344
Copy link
Author

Ok, I understand that part, but ideally I’d prefer not to use async. I just included the async bit to show that it does, in fact, load seabios if async is enabled.

@copy
Copy link
Owner

copy commented Jul 22, 2024

When you use async: false, v86 will load the entire file in a single xhr request, and use the resulting ArrayBuffer as the storage. ArrayBuffers are limited to 2GB in some browsers (https://stackoverflow.com/a/72124984).

We could handle this case transparently (by loading the file in 1GB chunks, or streaming downloads), but it's not clear that this is really useful (loading entire 3GB at once). If you want to improve disk speed, I'd suggest using async: true, use_parts: true, fixed_chunk_size: 1024 * 1024.

In any case, I will improve the code to print a useful error in this situation.

@copy
Copy link
Owner

copy commented Jul 22, 2024

The async: true case works fine for me, could use libv86-debug.js and check if there are any messages in the browser console?

@copy copy closed this as completed Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants