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

Source Maps Not Working on First Run #2379

Closed
mattdesl opened this issue Jul 29, 2015 · 20 comments
Closed

Source Maps Not Working on First Run #2379

mattdesl opened this issue Jul 29, 2015 · 20 comments

Comments

@mattdesl
Copy link
Contributor

Hey,

I've noticed that source maps are not applied on first run. After launching Electron, the user needs to re-load the page in order for the source maps to "kick in."

Here is a repo where you can reproduce the problem:

test-electron-source-maps (in branch test/first-run)

@davej
Copy link
Contributor

davej commented Sep 1, 2015

Just to add that I've found this bug in my own project too but occasionally source maps will work on first run. Perhaps about 1 time in 10 runs it will work first time without needing a reload. I thought it was worth mentioning since this possibly indicates a race condition.

@zcbenz
Copy link
Member

zcbenz commented Oct 1, 2015

Not able to reproduce in v0.33.3, seems to have been fixed when updating Chrome.

@zcbenz zcbenz closed this as completed Oct 1, 2015
@davej
Copy link
Contributor

davej commented Oct 2, 2015

Still Experiencing this in v0.33.4.

Here's a 34 second video recreating the bug: https://www.dropbox.com/s/r883d31jm1bpb9c/electron-sourcemaps-test.mov?dl=1 (39MB .mov)

And here's a repo of the code that I used, you can clone it to hopefully reproduce this on your dev environment: https://github.com/davej/electron-sourcemaps-test

@zcbenz zcbenz reopened this Oct 2, 2015
@freemountain
Copy link

I observe this issue on osx 10.11.

> process.versions
{
 "http_parser": "2.5.0",
 "node": "4.1.1",
 "v8": "4.5.103.29",
 "uv": "1.7.4",
 "zlib": "1.2.8",
 "ares": "1.10.1-DEV",
 "modules": "46",
 "openssl": "1.0.2d",
 "electron": "0.35.2",
 "atom-shell": "0.35.2",
 "chrome": "45.0.2454.85"
}

@davej
Copy link
Contributor

davej commented Oct 21, 2016

Just re-tested this with 1.4.4 and I can confirm this is still broken. Also updated the test case repo.

@codebytere
Copy link
Member

Closing due to abandonment.

@davej
Copy link
Contributor

davej commented Sep 27, 2017

@codebytere: What does 'abandonment' mean in this case? There is a test case repo, a video and 5 thumbs up indicating that other people are experiencing this issue.

Would you like me to confirm that the issue still exists in the latest version of Electron?

@codebytere
Copy link
Member

That would be great, thanks! We're just weeding out abandoned issues (issues that have seen no action in a significant amount of time) so if this is still an issue and you feel it's important to fix i'll definitely reopen it :)

@davej
Copy link
Contributor

davej commented Sep 27, 2017

Just re-tested this with 1.7.8 and I can confirm this is still broken. Also updated the test case repo.

@codebytere: Can you please consider reopening.

@davej
Copy link
Contributor

davej commented Sep 27, 2017

Also, OS and system spec information below in case it's relevant.

image

@codebytere
Copy link
Member

we're just weeding out abandoned issues, so if this is still in need of a fix i'll reopen :)

@codebytere codebytere reopened this Sep 27, 2017
@davej
Copy link
Contributor

davej commented Sep 27, 2017

[Off-topic: Feedback about marking issues as 'abandoned' (click to expand)]

@codebytere Thanks! I understand the desire to lower the number of open issues but "abandonment" seems like a short-sighted criteria. Often people don't want to spam an issue with "me too" comments when the issue is already described and they have no useful information to add. Please consider removing the "abandonment" reason for closing issues because it doesn't relate to the content of an issue. Closing issues because the team have decided they are "Wont fix" or "Can't reproduce" (or whatever) seems reasonable instead.

I noticed that #4368 was closed too, even though the bug still seems to be present. Thanks for your help 🙂, sorry for going off-topic.

@codebytere
Copy link
Member

codebytere commented Sep 27, 2017

@davej thanks for the input! i'll be more verbose in the future so that people can better understand why i might be closing something 😁

@dnichols
Copy link

Experiencing the same issue:

source-map-reload

@Kilian
Copy link
Member

Kilian commented Dec 6, 2017

I recently updated from webpack 1 to webpack 3.10, and am now also experiencing this issue:

  • if you start Electron without devtools open, sourcemaps don't work
  • if you reload (using location.reload()), they load correctly
  • if you start Electron with devtools open, sourcemaps work immediately.

@daviddelusenet
Copy link

I'm using Webpack 4 and am also experiencing this issue.

@mattdesl
Copy link
Contributor Author

I’ve fixed this in my app by waiting for devtools to open before navigating with loadURL/loadFile.

It makes sense that the Chrome debugger needs to be running to transform source maps. To me this seems like a Chrome issue, and not something Electron should try to fix.

@emusgrave
Copy link
Contributor

Expanding on what @mattdesl referred to, here is a snippet of code that waits for a devtools-opened event on the main window. You can adapt to your environment and then source-maps should always be loaded okay on the first try.

if (isDevelopment) {
    mainWindow.webContents.on('devtools-opened', () => {
        mainWindow.loadURL(...)
    }
} else {
    mainWindow.loadURL(...)
}

@MarshallOfSound
Copy link
Member

It makes sense that the Chrome debugger needs to be running to transform source maps. To me this seems like a Chrome issue, and not something Electron should try to fix.

This makes sense to me, based on the workaround it sounds like devtools needs to be open to fetch and parse these. Gonna close this one out 👍

@emusgrave
Copy link
Contributor

Update... for me, as of Electron 8, waiting for the 'devtools-opened' event stopped opening the devtools at all. The only way I could get devtools opened at that point was to hit ctrl-shift-i twice in fast succession. I've gone back to just attempting to open them without waiting for the signal, and crossing my fingers that the timing/source-map issue is fixed.

if (isDevelopment) {
    mainWindow.webContents.openDevTools()
    mainWindow.loadURL(...)
} else {
    mainWindow.loadURL(...)
}

Another option if the problem comes back might be to use the new method of opening the devtools in a separate window:

devtools = new BrowserWindow()
mainWindow.webContents.setDevToolsWebContents(devtools.webContents)
mainWindow.webContents.openDevTools({ mode: 'detach' })
mainWindow.loadURL(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests