-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
nc-ng in some circumstances doesn't open requested documents in tabs #253
Comments
This issue was brought up by @anjohnson in #249 . The core issue was two fold.
|
I don't think that first issue is completely fixed, sorry! The tests below were using nedit-ng version 2020.1-147-g63130309 on MacOS Mojave. Starting a server and trying to open 104 files in a single command gives me this:
and just a single "Untitled" window opens. When starting a server and opening 69 files though ( If the server is already running, asking for 69 files causes them all to open in separate windows (leaving the Untitled window also open) with no terminal messages. As those 69 windows open up each subsequent one seems to take longer than the previous one. The early ones aren't really noticable, but later windows seem to slow quite substantially with the last one taking almost a second to appear – not really a problem, but an indication of some kind of non-linearity in the code. If the server is already running, asking for 104 files just results in the same "QLocalSocket: Remote closed" message as above in the nc-ng terminal window. Thanks! |
So, yea if you get an error on the command line, you'll only see an untitled window. That's because it launched the server, which defaults to showing an untitled window, and then fails to open any documents. When the server is already running, is it on a separate desktop or anything like that? There is logic to try to find windows on the "current screen", but I'm wondering if it has flaws. As for the "Remote closed", that's disappointing that it is still an issue, I'll have to keep looking into it. Is there anything else you can tell me about your system that would help me reproduce the issue? working over ssh forwarded? Or just directly in macOS? I am wondering if macOS has unusually small pipe buffer sizes or something that needs to be worked around :-/ |
@anjohnson Can you give this PR a try and see if it helps at all? I don't know if you have X11 libs installed on your mac, but if you do then the nedit server would be using that to try to find existing windows (and maybe failing?). This makes it so on mac, it always using the "Qt way of doing things". I'd like to go pure Qt all the time, but there were other issues back in the day the first time I tried to do that :-P. |
In that case it was just regular MacOS, no X11 or ssh forwarding involved. I just built the same code on my RHEL-7.9 Linux system:
I'm connecting to that machine through NX, but to the applications it just looks like the local screen (DISPLAY is So yes it may be that the Mac has a smaller pipe buffer, is there a way to request a specific size for the pipe backing store when you create it? I don't have time to try your other branch right now but I will, maybe later tonight or tomorrow. |
Using this version:
Hmm, the first time I ran this I first started an Untitled server, then (after pasting the above from its About box) I ran my usual
Actually it looks like any attempt to use nc-ng to connect to a server results in a the server crashing with the same stack-trace, irrespective of how many files are requested or whether the server has any files open or not. With no server running, I could probably run this in a debugger if you want any more details, I do use VSCode. |
Looks like a NULL pointer (access to an address bear zero usually means a bull pointer reference via a strict member) I really need to setup a mac to test things! In other news, I reworked in both this and master how how list is sent to the server. Did that fix (in master) the issue of large lists failing? |
In NeditServer.cpp line 208: QScreen *current_desktop() {
return screenFromWidget(QApplication::activeWindow());
}
|
Yes, I think your fix in 9f50e44 has solved the problem of passing long lists of files from nc-ng to the server. I just realized that my issues have to be related to the fact that I'm using 2 screens on this laptop, the built-in one and a TV, and all my tests have been run from a terminal window on the TV. |
@anjohnson Yea, I think I see what's going on here... maybe. I have an idea of how to fix it, but we'll see if it works. Basically, I think that the code to "find a window on the 'current desktop'" is always failing, even after creating a window. So I think the solution is that if a window is created at all, then remember that one and use it as the target for future documents regardless of which desktop it happened to open on, because that one is by default the "current desktop" now. And yea, fixing that NULL pointer should be easy. I guess Qt on macOS doesn't consider a window active until after it is made visible by the OS or something? |
I suspect the issue is that the code to find what screen a window is on may be returning a different result at different times. You have multiple threads here, and this evidence that I found earlier should be explainable by whatever theory you come up with:
Actually that description might be slightly wrong, the difference seems to be whether the focus belongs to the Untitled window when the server is looking for it. Using this: |
…" for the nedit server. Maybe fixes issue #253 ?
@anjohnson Can you give master another go, I just made a small tweak in light of the fact that sometimes there isn't an "activeWindow" yet. |
No change; if I drag the Untitled window to the built-in screen a subsequent Feel free to send me a patch that prints out each window's screen identifier while it's looking through the list for the right window (and don't forget to also print what it's trying to match with)... |
…e have to create a window, make sure to use that window for future documents we need to open (only in the context of an nc request)
@anjohnson can you try this PR? #257 ? It tries extra hard to use the same window for all documents opened by a single nc request. |
The branch $ nc-ng # Create Untitled window on TV.
# Move mouse & focus back to terminal, still on TV.
$ nc-ng src/*.h # Creates 104 windows on TV, each one slower to open than the previous. Whereas: $ nc-ng # Create Untitled window on TV.
# Drag Untitled window to laptop screen.
# Move mouse & focus back to terminal on TV.
$ nc-ng src/*.h # Opens 104 tabs on what was the Untitled window on laptop screen. and: $ nc-ng # Create Untitled window on TV.
# Move mouse & focus back to terminal on TV.
$ sleep 5; nc-ng src/*.h # Click in Untitled window during sleep.
# Opens 104 tabs on what was the Untitled window on TV. Please concentrate on how NeditServer.cpp identifies which screen each window is displayed on, and which is the "current" screen. The server properly finds an Untitled window on the TV if it has the keyboard focus when |
I just corrected the final example above, it should have read "Untitled window on TV" |
@anjohnson that is VERY surprising. Because I added code specifically to say "whatever window you opened a document in, use that one again". So I was expecting it to at most create one new window with 104 tabs :-(. I'll keep hacking at this though, I'm sure I'll get to the bottom of it eventually! |
@anjohnson I think I'll have to whip out an old mac mini and see if I can replicate this locally. Unfortunately without being able to reproduce it, it's a challenge to know if I'm on the right track :-(. |
… that it can help address issue eteran#253
…" for the nedit server. Maybe fixes issue eteran#253 ?
@anjohnson First of all, sorry for the radio silence on this one, but it's been a bit of a crazy busy year. But I have good news! @sjtringali tying you in since I have a "how should this work" kind of question at the end.
I have a complete picture of what is happening: Firstly, Given that there isn't always an active window, it's not always easy to determine which screen the user should expect the new window to be on. Finally, it gets a little quirky since (at least on windows), there is a concept of a "primary screen", which should be where new windows are expected to be created... but it seems to want to create them where the last window was. So here's the deal. I need the nedit server to make a decision of "is there already a window on the screen where I want to make one" if so, make a new tab, if not, make a new window. Sounds easy, but here's where it falls down: When I place the first main window on screen It gets worse! When we open multiple files like this, it can create a new window for each one since that check fails over and over. So on to my question of "what does the user expect". I can PROBABLY track the last main window which had any focus at all, if it still exists, assume they want a new tab in that one. What are your thoughts? |
I’ll have to try this out tomorrow to see.
Most apps are pretty horrible at this anyway. Always using the primary screen is annoying, but, so is always using the screen that has your mouse cursor. First case is ignoring your perfectly valid case to group things together, and the second case, it’s annoying when you try to switch away from a screen in order to do something else, most often when something is taking a long time and blocking an application… And then a new window pops up from the old application on top of your current screen which you don’t want. So my answer is to try to design for both cases.
Probably, you can store the last activated window. If there is no currently active window, then use the same screen as that one.
… On Dec 14, 2021, at 10:49 PM, Evan Teran ***@***.***> wrote:
@anjohnson First of all, sorry for the radio silence on this one, but it's been a bit of a crazy busy year. But I have good news!
@sjtringali tying you in since I have a "how should this work" kind of question at the end.
I have a mac to test this on :-)
I've replicated the issue (even on windows!)
I have a complete picture of what is happening:
Firstly, activeWindow() is indeed allowed to return NULL if no window is active, like if you are currently typing in a terminal, none of the nedit-ng windows are active.
Given that there isn't always an active window, it's not always easy to determine which screen the user should expect the new window to be on.
Finally, it gets a little quirky since (at least on windows), there is a concept of a "primary screen", which should be where new windows are expected to be created... but it seems to want to create them where the last window was.
So here's the deal. I need the nedit server to make a decision of "is there already a window on the screen where I want to make one" if so, make a new tab, if not, make a new window.
Sounds easy, but here's where it falls down:
When I place the first main window on screen 1 with a terminal on screen 0. Qt reports screen 0 as my primary, which makese. But then when I use nc-ng it creates the window on screen 1! Because nedit-ng said "OK, I the primary screen is 0, but the only window I have is on screen 1. So I should create a new window...
It gets worse!
When we open multiple files like this, it can create a new window for each one since that check fails over and over.
So on to my question of "what does the user expect".
I can PROBABLY track the last main window which had any focus at all, if it still exists, assume they want a new tab in that one.
I can DEFINITELY say "just always create new tabs in one of the existing windows, prioritizing based on age"
Could implement a different behavior I'm not currently thinking of too.
What are your thoughts?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
That certainly seems to explain what's happening. I think the most important thing is probably that if I ask Supposedly the option Thanks! |
@anjohnson OK, I think and hope that this PR will help with this. It does a few things:
I know it's been a bit, but when you have a chance, can you see if this solves the issue for you since you've been best able to reproduce the problem? |
Getting warmer, but that doesn't fully explain this:
I did just trigger these too, which are a bit different:
Originally posted by @anjohnson in #249 (comment)
The text was updated successfully, but these errors were encountered: