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

Updated frontend: fixed search through Drawer panel. #621

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcominetti
Copy link
Contributor

Implemented DebuggerAgent.searchInContent.
Implemented PageAgent.searchInResource.
Added /lib/search.js to provide shared search functions.
Added resource/script source caching.
Fixed highlighting matches bug on minified-file lines.

@marcominetti
Copy link
Contributor Author

@3y3 This is not an easy pick pr... I'll push some more commits with syntax and code cleanup for linter... but I know we'll talk about the source code caching in DebuggerAgent implementation... :D

@3y3
Copy link
Member

3y3 commented May 12, 2015

@marcominetti , sorry for pending of your features, but there is a lot of bugs, which I need to fix and release before review.

@marcominetti
Copy link
Contributor Author

@3y3, wow I've seen the new issues right now... may I help you? Feel free to assign me something. ;)

@3y3
Copy link
Member

3y3 commented May 14, 2015

Hello, @marcominetti , I target you from Plugin system pr. Also you can look on 0.10.2 milestone, here are bugs and features with hight priority. It is not necessary, what all this bugs needs to be fixed, in some situations we need only to describe solution. For example #566 - you are friendly with new front-end, so you can target man to entry point for this feature (or implement it by yourself).
So look at list, and if you ready to fix something - notify me.

@marcominetti
Copy link
Contributor Author

@3y3 I can work on #566 and #580...

@marcominetti
Copy link
Contributor Author

Let me know if you have any priority... ;)

@marcominetti
Copy link
Contributor Author

Please notify me when you will be ready for review this pr... cause I'm thinking about reworking it after changing the internal behaviour incase of --no-preload param...

@3y3
Copy link
Member

3y3 commented May 15, 2015

I can work on #566 and #580...

Nice! Thank you! For #580 look also on #628. I think it's a duplication. In #628 posted good example for tests. (For correct installation delete npm-shrinkwrap)

Please notify me when you will be ready for review this pr... cause I'm thinking about reworking it after changing the internal behaviour incase of --no-preload param...

--no-preload was changed somewhere?

@marcominetti
Copy link
Contributor Author

--no-preload was changed somewhere?

Not yet, I will elaborate the clue later on reviewing/reworking this pr... btw the ni stack is built to run "locally", so the --no-preload does prevent backend to feed frontend with every available file from disk... (am I right?) I use it to have frontend load quickly and smoothly in large project...

The problem is that the --no-preload flag also avoids frontend feeding the static content provider (at front-end) for actually loaded files... This dramatically impact search, because, at first run, it needs to fetch source code for every loaded file... I will try to override the --no-preload behaviour assuring that script content is fetched automatically for loaded files and stored within the static content provider...

@cr0cK
Copy link

cr0cK commented May 15, 2015

+1 for #628 !

@a7madgamal
Copy link

Guys please work on this its a really important feature!
Thanks a million in advance :)

@marcominetti
Copy link
Contributor Author

hi @a7madgamal @3y3 I've successfully implemented the feature but there is a huge memory consumption cause I need to cache/preempt source files in arrays because search feature generates very huge number of getScriptSourceById/getResourceContent requests to the debugger through DebuggerClient and everything crashes... I could cache source in /tmp/ filesystem (but it's not so clever in cloud environments for the I/O)...

Solutions:

  1. fix debugger client or debugger backend crash on huge requests (best)
  2. implement an ordered queue at getScriptSourceById and getResourceContent (@3y3?)
  3. keep this implementation and/or move cache on disk (worst)

You can try implementation with ljve-inspector module available on npm (I use it actually).

@a7madgamal
Copy link

I can't find it, could you provide the npm link?

@marcominetti
Copy link
Contributor Author

@3y3
Copy link
Member

3y3 commented Jul 1, 2015

@marcominetti , I'm not familiar with search API in DevTools, but if I understand right main problem - we receive lot of parallel requests like searchInContent and we try to require sources for each scriptId also in parallel mode. So, we need to review strategy of original DevTools, when there exists a linked local folder:

  • If in this case DevTools tries to search in all files (not only in loaded to front-end), then we need to completely avoid getScriptSourceById and use fs (this makes some problems for generated scripts, but I prefer to ignore this problems in initial implementation)
  • Otherwise we can move search logic to app (look at injection example in ConsoleAgent)

In all this cases we need to completely avoid caching.

So, main question on current step - are we need to search in preloaded resources?

try {
regexObject = new RegExp('^.*?'+query+'.*?$|^.*?'+query+'.*?\n|\n.*?'+query+'.*?\n|\n.*?'+query+'.*?$', regexFlags);
} catch (e) {
// Silent catch.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the try-catch block really necessary? which case the RegExp will throw an error?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yorkie , I'm not sure that this is a best time to review internal structure of this pr. At current step we need to decide how to avoid caching. Read my last comments.

Relative to your question:

new RegExp('abc[')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway it would be nice if you'll help me with review!

@a7madgamal
Copy link

@marcominetti I installed your fork and its working greatly but when i search and click on a line it always highlight the NEXT line!
I want you to confirm this and if it turns out to be a bug I think I can help you fix it quickly
HINT:check the function getLine(doc, n) return chunk.lines[n]; in the "codemerror.js" file should be n-1 if n > 0

@3y3 I think it's ok for the search process to be a little bit slower and works like 10 files at a time then next 10 etc. for a basic fix. After all it's better than nothing!

@3y3
Copy link
Member

3y3 commented Jul 1, 2015

@a7madgamal , I agree that we must sacrifice performance for stability

@marcominetti
Copy link
Contributor Author

@a7madgamal yep the bug of next line is fixed within an unpublished version... I'll publish it after some cleanup...

@marcominetti
Copy link
Contributor Author

@3y3, I'm busy but I'll try to comment code just to share the pr/strategy... and I think the best way to improve stability and avoid memory leak is to directly check the filesystem if the file exists and, if not, trying to get through debuggerclient with requests "pagination"... do you agree?

@marcominetti
Copy link
Contributor Author

@3y3 hi, i'll have to work on this next weekend... just to confirm, i'll do:

  • remove caching and
    • read script contents from fs
    • eventually pool by X when fs is not available/exist
  • include fix for wrong-next-line

@marcominetti
Copy link
Contributor Author

@3y3 I've rebased against 0.11.1, reverted most of the code and switched to original functions extracted from frontend... It seems to work now. Performance are not exciting but no memory leaks. We can drop my custom implementation with regexp (commented code in SearchOverrides.js and _xxx "private" named functions in search.js). After review I'll fix the jshint stuff...

return new RegExp(regex, flags || "");
}

exports.performSearchInContent = function(content, query, caseSensitive, isRegex)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@3y3 this code is adapted from /front-end/common/ContentProvider.js implementation...

@3y3
Copy link
Member

3y3 commented Jul 15, 2015

Hello @marcominetti , sorry for ignoring your previous comment - I'm very busy at this time. I'll review your changes as soon as possible. I'm not sure that this will happen today, but definitely on this week.

@3y3 3y3 force-pushed the master branch 2 times, most recently from cd779b6 to e3d08ea Compare September 28, 2015 23:28
@fakenickels
Copy link

Waiting for this =) @3y3

@marcominetti
Copy link
Contributor Author

Hi @grsabreu, in the weekend I'll check the status against latest commits to the master branch... are you experiencing specific problems?

@3y3
Copy link
Member

3y3 commented Jan 13, 2016

@marcominetti , please don't miss time at current weekend. I'll release "Node Inspector Next" at this month (I hope) with new frontend and completely reimplemented server. So it's not reasonable to rebase at current master.

Node Inspector Next breaks compatibility with oldest node versions (compatibility starts with 4.*), but implements lot of new features.

I'm sorry that I pending this pr, but each time then I start to review it, there happens new broken node release.

@marcominetti
Copy link
Contributor Author

@3y3 cool! Do you need help on nin?

@a7madgamal
Copy link

any updates?

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

Successfully merging this pull request may close these issues.

None yet

6 participants