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

Screen goes black #2768

Closed
uhhhclem opened this issue Jan 23, 2022 · 30 comments
Closed

Screen goes black #2768

uhhhclem opened this issue Jan 23, 2022 · 30 comments

Comments

@uhhhclem
Copy link

Bitburner v1.4.0 [49de4a2]

Can't seem to find any specific cause or trigger for this: Sometimes the whole screen goes black and I have to refresh to continue playing.

Tried to upload a recent save file, but mislav/hub#1479 appears to be blocking.

@kotenok2000
Copy link

kotenok2000 commented Jan 24, 2022

Put it in zip archive with 7zip
it works for me
test.zip

@uhhhclem
Copy link
Author

For what it's worth, it seems that this is happening when the game is saving. I have the game set to save every 10 minutes, because whenever it saves, it stops the world for 10-15 seconds, or longer. Every few times, I get the popup message suggesting that hey, maybe I have an infinite loop in my script and do I want to restart? (I cancel and let the save complete.)

I believe (from looking deeper into mislav/hub#1479, that I can't upload my save file because it's too large - it's 55mb zipped. So I uploaded it to my Google Drive - https://drive.google.com/file/d/1CfX-r5yVWu_AU-QKKS119Dk2n9Gw0ybc/view?usp=sharing

@uhhhclem
Copy link
Author

Also, I should say that by "sometimes the screen goes black" I mean "reliably, several times a day."

@upsided
Copy link

upsided commented Jan 28, 2022

I got this too on the steam client & chrome (firefox worked fine, though). Thinking it was memory related, I recently tried --js-flags="--max_old_space_size=8192” as run arguments and haven’t gotten the black screen yet. (steam client, approx 1 hr of playing)

@phyzical
Copy link
Contributor

@uhhhclem can you confirm if this flag helps at all?

@gholub
Copy link

gholub commented Feb 18, 2022

I have been seeing a similar issue for several days now. I tried adding the js-flags to the run arguments for the steam client, but it did not solve the issue. Attached is my save file as well as main.log.

This exception appears to be causing the issue:

[2022-02-17 18:46:14.933] [error] Unhandled Exception UnhandledRejection Error: Render frame was disposed before WebFrameMain could be accessed
    at Object._send (<anonymous>)
    at Object.n._sendInternal (electron/js2c/browser_init.js:165:558)
    at Object.b._sendInternal (electron/js2c/browser_init.js:161:2571)
    at electron/js2c/browser_init.js:201:729
    at new Promise (<anonymous>)
    at Object.invokeInWebContents (electron/js2c/browser_init.js:201:477)
    at Object.b.executeJavaScript (electron/js2c/browser_init.js:161:3265)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
[2022-02-17 18:46:15.143] [warn]  Forcefully crashing the renderer process

bb1.4.0(49de4a28)_blackscreen_17022022.zip

@zigdon
Copy link

zigdon commented Feb 28, 2022

Running into this too, with the steam client. My theory is that it's happening when an auto-save is triggering while a manual save is already running. My saves are now taking a few seconds to run, so it's not that uncommon that auto-save would try to happen while I'm in the middle of saving via the editor

@zigdon
Copy link

zigdon commented Feb 28, 2022

Nope - disabling 'save game on file save' didn't make this go away, so it's not (only) concurrent save games.

@zigdon
Copy link

zigdon commented Mar 2, 2022

From discord, someone suggested clearing out large files in my safe, and doing so did get rid of the problem.

@OriginalRobotWizard
Copy link

I am using the Steam version and this happens to me frequently, multiple times during the day, in different intervals. It can happen anywhere between 0.5 to 8 hours.

It started to happen when I started to use singularity functions to automate crimes, and work for factions. I saw the screen go black a single time with my eyes. A crime was about to be finished, but then the game went black before displaying the crime selection screen. All other times I come back to a black game window, the game is pretty much in the background, or on another screen, so it's not easy to point down when it happens.

It is not related to saving, as it also happens when auto save is off.

Adding the js-flags argument does not prevent the behaviour.

The largest file I have is 200kb, with a total unkompressed save of 4 MB.

@phyzical
Copy link
Contributor

phyzical commented Mar 6, 2022

@OriginalRobotWizard could you please try the beta branch "development" in steam to see if it still occurs? (backup your save just incase) there has been some changes around save corruption fixes

@OriginalRobotWizard
Copy link

OriginalRobotWizard commented Mar 6, 2022

Using Steam version beta "development" ec44c9d, the game window went black after about 7 hours.

@OriginalRobotWizard
Copy link

Steam version beta bc95214 still has the issue.

@phyzical
Copy link
Contributor

phyzical commented Mar 9, 2022

@OriginalRobotWizard thx for keeping the ticket up to date, did you happen to maybe be working/ commiting crimes and then your script tried to install augmentations by chance?

@phyzical
Copy link
Contributor

phyzical commented Mar 9, 2022

i have a pr (#3101) open to fixe a crash related to augmenting when working, and there was a stale reference to the player object when commiting crimes too so fingers crossed that miight be it

@OriginalRobotWizard
Copy link

I noticed that after the black game window, and then reloading the game, that then the API Server stopped working. And it can not be made working again by simply disabling and enabling it. The game has to be closed and reopened for the API Server to work again.

@phyzical
Copy link
Contributor

changes look to be merged @OriginalRobotWizard hopefully itll work this time (whenever the dev branch build is updated next)

@OriginalRobotWizard
Copy link

Steam version beta ca19e15 still has the issue. Let me know when your changes are live and I will keep this ticket up to date.

@OriginalRobotWizard
Copy link

OriginalRobotWizard commented Mar 15, 2022

Steam version beat b265d7b still has the issue. It is happening unrelated to installing augmentations. The script is just working for factions and committing crimes.

@phyzical
Copy link
Contributor

phyzical commented Mar 15, 2022

damn.... okay lets try this again.

so before you said it happens right before crimes finish, is this always the case or does it occur at random times too?

how do you handle your scripts are they just simple scripts that loop and wait for conditions or are you using like the more magical methods tail, exec, onExit ect?

@OriginalRobotWizard
Copy link

OriginalRobotWizard commented Mar 18, 2022

Still happened on the update before f17e685 (I did not take note which commit that was). Not happened on f17e685 for now, presumably because I only installed it a few hours ago.

Up until now, I was unable to exactly determine the point of my controller, of what it is actually doing, since when I reload, the last save is loaded and thus logging in gone. So I made an external logging server using NodeJS and ns.wget() to have live external logging. Black screen happened 2 times, since then. Both at the same log entry ("Start do-Faction-Work"). I have extended the logging in that particular part now.

So, how do I handle my scripts in that part of my controller? As with any other part where I use singularity, I am using all kind of magical methods to save on RAM on the controller. In this case in particular:

In the controller:

let pid = ns.run("appSingularityWorkForFaction.js", 1, targetFaction);
    while (ns.ps().filter(process => process.pid == pid).length)
        await ns.sleep(100);

In appSingularityWorkForFaction.js:

export async function main(ns) {
    let targetFaction = ns.args[0];
    
    if (ns.workForFaction(targetFaction, "hacking contracts")) {
        while (ns.isBusy()) {
            await ns.sleep(9000);
            ns.stopAction();
        }
    }

    if (ns.workForFaction(targetFaction, "field work")) {
        while (ns.isBusy()) {
            await ns.sleep(9000);
            ns.stopAction();
        }
    }

    if (ns.workForFaction(targetFaction, "security work")) {
        while (ns.isBusy()) {
            await ns.sleep(9000);
            ns.stopAction();
        }
    }

    await ns.sleep(100);
}

As I said, I have extended the logging now, so that I may be able to determine further, which of the lines causes the issue. Its worth noting, that the black screen appearance has hours of working game in between, where this particular function called over and over.

As I said, I am doing similar things for committing crimes, and all other singularity functions that just do stuff, instead of returning data. I have now extended logging in all those cases and may be able to point down on the ns calls that are made before back screens happen. (Or it magically disappears now, be it by timing of logging, or a new version of this absolutely fantstic game).

@OriginalRobotWizard
Copy link

bitburnerSave_1648101328_BN4x2.zip
Hello, I have new insight. It seems to be a memory leaking issue. I have closely watched what happens over time, and it is the RAM usage of BitBurner Steam and Browser version slowly climbing up over time. When it reaches about 8 GB, the screen goes black and RAM usage drops to about 125 MB.

Please find attached a minimal setup save that reproduces the issue.

All the save does is, using 2 Scripts:

  • start.js: Starts work.js (using run) in a closed loop with a short sleep and waiting for the script to end (it uses tail() to open a window to be able to stop)
  • work.js: Works for a faction for one second and then stops working

It will take hours to reach the point of black screen (like in the normal save), but already after a short time the RAM increase is visible in the Task Manager.

@JesseFL
Copy link

JesseFL commented Jun 6, 2022

I just started to experience this on Steam version 1.7.0 (00adc2f). I am still early in the game on the first bitnode, no singularity. I was focusing on working for a faction when the screen just went black for no reason. I go to Reloads -> Reload (F5) to reload the game, and it hangs until it tells me I might have an infinite loop and I have to reload and kill scripts to get it back.

It has happened 3-4 times now in the past two days. It was stable for me before last week.

@JesseFL
Copy link

JesseFL commented Jun 6, 2022

I am observing the same behavior reported by @OriginalRobotWizard , except in my case when Bitburner hits about 4150mb the screen goes black and RAM usage drops down to about 140mb.

@DoctorPolski
Copy link

DoctorPolski commented Jul 6, 2022

@phyzical I'm seeing this issue and I have a very simple case to demonstrate it.

I only started playing a couple of days ago and am using the Steam version @ 1.7.0.

I have a created a simple environment that autoscales player purchased servers to hack/weaken/grow commercial servers. Each player server runs many copies of 1 single-threaded script that in turn will hack/weaken/grow a single target. When there is enough money to buy a new player server it does so. If we are at the player server limit it will delete a single, smaller server if one exists and replace it with a new, bigger server.

As you can imagine this scales very quickly and was great fun to watch... until it wasn't. From a completely cold start, with no active scripts I run my initiator script and RAM usage climbs very quickly. Within a couple of minutes the screen goes black and hitting F5 eventually gives the "did you not wait for an async fn?" pop-up. This is not the case.

As observed by others in this issue thread the RAM usage of the exe drops right down to around 150MB when the screen goes black.

I have done nothing else in game so far. No factions, no jobs, no gangs. Just NUKE'd all the immediate scan targets and set an autoscaling bot army after them...

I can no longer play the game for more than a few minutes.

Would a save file help here? My system specs etc?

UPDATE: I have just made an interesting observation. Once the game is loaded and the game window remains focused the game runs. But, within 3 - 4 seconds of the window losing focus the game crashes to black screen.

UPDATE 2: After more digging it seems I'm hitting the infamous 4GB V8 garbage collection limit. I've tried everything to increase that limt with every --max-old-space-size variation I can think of but it's still only allocating 4GB. Has anyone used a variation of that and actually seen the memory usage increase past the 4GB default limit in a 64-bit environment?

@phyzical
Copy link
Contributor

phyzical commented Jul 7, 2022

i want to say i have seen it get above 4gb but this was probably 6 months ago, you could also try googling electron + default limit as it might be an electron specific adjustment.

the other option is to just make some calculations to use multi threaded scripts instead of a bazzillion single thread scripts, as you will probably hit the limits again even if you did increase it

@DoctorPolski
Copy link

Multi-threading was definitely the way to go. It'll be a while before I hit RAM limits again... 😁

@ElFisho2
Copy link

Hello,
A script I was writing started crashing with a black screen immediately after running it so I started deleting stuff to find the problem. I'm not sure that this will help solve the issues that the other people have, but I found a way to black screen instantly by running the following script:

/** @param {NS} ns */
export async function main(ns) {
	Object.prototype.a = function(){}
}

For me this crashes on both google chrome and steam even in a new save. I hope this helps : )

Ok. I thought I was done, but in the middle of writing this I changed Object.prototype.a to Object.prototype.aa (or anything with more characters) and it brought me to a recovery screen instead of a black screen, so...
I'm not sure if this should be submitted separately or something, but because it's related I will include the report here.

TypeError: Cannot read properties of undefined (reading 'format') (at "Terminal")

How did this happen?

I ran crash.js which is:

/** @param {NS} ns */
export async function main(ns) {
	Object.prototype.aa = function(){}
}

Environment

  • Error: TypeError: Cannot read properties of undefined (reading 'format')
  • Page: Terminal
  • Version: v1.7.0 (cfcdc25)
  • Environment: Production
  • Platform: Browser
  • UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
  • Features: lang=en cookiesEnabled=true doNotTrack=1 indexedDb=true
  • Source: n/a

Save

happens on a fresh save file but here
aa bitburnerSave_1658432341_BN1x1.txt

P.S.
I've also been recently getting the random black screen every so often (probably the memory reasons discussed in earlier comments)

@ElFisho2
Copy link

@hydroflame It looks like you closed this issue while I was writing my last comment. I was 8 minutes too late (what a coincidence!) and I think the issue should be reopened. (I don't have the reopen button)
: )

@HoveringGoat
Copy link

I dont think this is resolved. I'm getting this on 1.7. I spent a few trillion on upgrading my home ram and now loading my main hacking script it spawns too many scripts and crashes the game.

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