Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Debugging is difficult/impossible when attempting code modifications #922

Closed
2 tasks done
TheCleric opened this issue Mar 15, 2020 · 10 comments
Closed
2 tasks done
Labels

Comments

@TheCleric
Copy link
Collaborator

TheCleric commented Mar 15, 2020

Bug description
When modifying nativefier source in order to implement a "Find" menu command, debugging is difficult because logging seems to get swallowed. I've tried the following:

  • console.log (which seems to output to command line for the main process in an electron app, which nativefier doesn't seem to have since it's an app)

  • The electron-log library which does not seem to actually output any files

  • Using the fs.appendFile function directly to implement my own logging system also seems to not create any files as directed

  • Using executeJavaScript to inject the log message into the dev tools console which does not actually display

  • Using the --verbose command line option which I can not seem to find any effect of using

  • I looked at nativefier --help and https://github.com/jiahaog/nativefier/blob/master/docs/api.md , I'm sure I'm not misunderstanding expected behavior.

  • I searched existing open & closed issues. Yes, my bug is new.

Steps to reproduce

  1. Download the nativefier source code
  2. Use one of the following logging methods mentioned above in menu.js as an item click event
  3. From the root of the project, run npm run clean && npm run-script build && node lib/cli.js https://myth-weavers.com/ --name "Myth Weavers" ~/Downloads/ && open ~/Downloads/Myth\ Weavers-darwin-x64/Myth\ Weavers.app --args --inspect --verbose
  4. Wait for app to launch
  5. Click the menu option that was added

Expected behavior
I would expect to see a debug log somewhere, preferably in the dev tools console, but in a file if that's not available.

Actual behavior
No logging occurs.

Logs & screenshots
Command output Logs:

nativefier@7.7.1 clean /Users/adam.weeden/Dev/nativefier
gulp clean

[03:50:52] Failed to load external module @babel/register
[03:50:52] Requiring external module babel-register
[03:50:52] Using gulpfile ~/Dev/nativefier/gulpfile.babel.js
[03:50:52] Starting 'clean'...
[03:50:52] Finished 'clean' after 12 ms

nativefier@7.7.1 build /Users/adam.weeden/Dev/nativefier
gulp build

[03:50:53] Failed to load external module @babel/register
[03:50:53] Requiring external module babel-register
[03:50:53] Using gulpfile ~/Dev/nativefier/gulpfile.babel.js
[03:50:53] Starting 'build'...
[03:50:53] Starting 'clean'...
[03:50:53] Finished 'clean' after 6.87 ms
[03:50:53] Starting 'build-cli'...
[03:50:53] Starting 'build-static-js'...
[03:50:53] Starting 'build-static-not-js'...
[03:50:54] Finished 'build-static-not-js' after 240 ms
[03:50:54] Finished 'build-static-js' after 299 ms
[03:50:54] Starting 'build-static'...
[03:50:54] Finished 'build-static' after 18 μs
[03:50:54] Starting 'build-app'...
[03:50:55] Version: webpack 4.42.0
Built at: 03/15/2020 3:50:55 AM
Asset Size Chunks Chunk Names
main.js 425 KiB 0 [emitted] main
main.js.map 345 KiB 0 [emitted] [dev] main
Entrypoint main = main.js main.js.map
[03:50:55] Finished 'build-app' after 1.19 s
[03:50:55] Finished 'build-cli' after 1.52 s
[03:50:55] Finished 'build' after 1.53 s
packaging [============================== ] 60%Packaging app for platform darwin x64 using electron v5.0.13

Context

  • Nativefier: 7.7.1
  • Node.js: 11.14.0
  • Npm: 6.7.0
  • OS: OSX 10.15.3
  • Additional context: None
@TheCleric TheCleric added the bug label Mar 15, 2020
@TheCleric
Copy link
Collaborator Author

Nevermind, I always seem to have a breakthrough right after I've given up.

Was able to get the console.log to show with the following change to the launch command:
npm run clean && npm run-script build && node lib/cli.js https://myth-weavers.com/ --name "Myth Weavers" ~/Downloads/ && ~/Downloads/Myth\ Weavers-darwin-x64/Myth\ Weavers.app/Contents/MacOS/Myth\ Weavers --inspect --verbose

Notice the replacement of opening the app with the calling of the actual executable in the generated app contents.

This leaves the command line blocked while the app runs and outputs the console log messages there.

Sorry for the annoyance.

@ronjouch
Copy link
Contributor

@TheCleric glad you figured it out 🙂! So, what was missing in your case, and is there anything we can improve in our developer docs for better clarity and visibility?

@TheCleric
Copy link
Collaborator Author

I would be specific that when making a code modification, console.log debug messages from the main process will be outputted to the command line (per Electron). Also give an indication on how to run the app from a command line for the various platforms so that the console.log messages will be visible. This should be fairly obvious (to me) for Windows and Linux, but is a bit more esoteric (to me) for OSX (but some people would probably say these are all obvious, lol).

@ronjouch
Copy link
Contributor

I would be specific that when making a code modification, console.log debug messages from the main process will be outputted to the command line (per Electron). Also give an indication on how to run the app from a command line for the various platforms so that the console.log messages will be visible. This should be fairly obvious (to me) for Windows and Linux, but is a bit more esoteric (to me) for OSX (but some people would probably say these are all obvious, lol).

@TheCleric nah, good comments, thanks. The development world is vast and what's obvious to Alice is brainfuck to Bob, so I enriched development.md in 19e4e4c

@ronjouch
Copy link
Contributor

@TheCleric by the way, if working on big new stuff, wait a bit for #898 to land, or you're in for a hell of a conflict resolution. And tests welcome for your use case with branch ts (see instructions at #898 (comment) ), I'm going to merge this today or next week.

@TheCleric
Copy link
Collaborator Author

Will do. Let me know when it's ready. I'm planning on adding this Find In Text feature, and as well a possible adblock option flag.

@ronjouch
Copy link
Contributor

Will do. Let me know when it's ready. I'm planning on adding this Find In Text feature, and as well a possible adblock option flag.

@TheCleric Nativefier 8.x is getting stable as of 8.0.4, so now would be a reasonable time for you to try adding these features. Relevant issues for both, with potentially-interesting ideas and implementation options:

@TheCleric
Copy link
Collaborator Author

TheCleric commented Mar 18, 2020

Yeah seeing #29 is what spurred this on, and I have a few ideas that aren't brought up in #177. Specifically following along with this thread:

https://discuss.atom.io/t/resolved-adblock-for-electron-app/39396/6

And possibly using this node library mentioned therein:

https://www.npmjs.com/package/abp-filter-parser

I've got search about half working at the moment (get a search dialog to show up, performing a search, getting a match count) but running into a few snags (search box losing focus on input event, search matches no highlighting like they were when I began testing this at a lower level). Gonna keep working on it, but would be open to a collaboration if you have time. 😄

@ronjouch
Copy link
Contributor

@TheCleric cool. Sure, please write and share your questions in the two issues:

@TheCleric
Copy link
Collaborator Author

Sounds good.

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

No branches or pull requests

2 participants