Skip to content

Conversation

@publixsubfan
Copy link
Contributor

@publixsubfan publixsubfan commented Jun 5, 2021

Summary

  • Uses threads instead of fork() to open new windows for an incoming session. Each thread is associated with a single window and problem state, and handles scene operations and rendering to OpenGL.
  • Adds an SdlMainThread class to deal with operations that need to be handled on the main thread, such as event handling and window operations. This class is instantiated once for a program, and essentially operates as a "server" which accepts commands from session threads.
    • This is required for Windows and Mac OS X; both systems only expect a single thread to handle events. Worse, Cocoa expects this to be the main program thread only.
  • Splits server code into a new function, GLVisServer(), which runs on its own thread.
  • Enables preliminary support for building natively on Windows using CMake.

TODO

  • Get glvis-js working with these changes
  • Testing for issues

@publixsubfan
Copy link
Contributor Author

Never mind, it was a missing define in the makefile. It should work now.

@pazner
Copy link
Contributor

pazner commented Jun 29, 2021

Never mind, it was a missing define in the makefile. It should work now.

Works now, thanks!

@camierjs
Copy link

camierjs commented Jul 6, 2021

The overall behavior looks really good - thanks @kanye-quest !

I have just encountered the following exit/Ctrl-C difference: after hitting the q key in a window, I'm not able to Ctrl-C the server in the terminal anymore.

However, if I click on the dock icon, then everything shuts down normally.

@tzanio
Copy link
Member

tzanio commented Jul 6, 2021

I still see issues with the lor-transfer (cf. #174 (comment)). While the windows are arranged correctly now:

Screen Shot 2021-07-06 at 9 52 43 AM

some of them have scaled viewport which can be seen in the caption (letters have scaled width) and when you zoom in:

Screen Shot 2021-07-06 at 9 56 59 AM

Can you reproduce?

@tzanio
Copy link
Member

tzanio commented Jul 6, 2021

I have just encountered the following exit/Ctrl-C difference: after hitting the q key in a window, I'm not able to Ctrl-C the server in the terminal anymore.

I will also like to be able to close the server with Ctrl-C in the terminal if possible

@tzanio
Copy link
Member

tzanio commented Jul 6, 2021

Not sure if this is a change in this PR, but the handling of ( and ) is incorrect -- they should only resize the window without affecting the centering of the image. This affects for example the minimal-surface miniapp in miniapps/meshing

Copy link
Member

@tzanio tzanio left a comment

Choose a reason for hiding this comment

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

Please document in CHANGELOG

@tzanio
Copy link
Member

tzanio commented Jul 7, 2021

I can confirm that e380892 fixed #174 (comment) and #174 (comment) for me.

Copy link
Member

@tzanio tzanio left a comment

Choose a reason for hiding this comment

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

This is a pretty major overhaul of the GLVis server internals, that I'm pretty sure would not have happened without your help @kanye-quest -- Thank you! 🎉 🎉 🎉

All my testing has been good for a while now, so I am approving with the expectation that continued use may uncover some issues in corner cases. 👍

@pazner and @camierjs -- Thanks for reviewing!

Copy link
Contributor

@pazner pazner left a comment

Choose a reason for hiding this comment

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

Very nice quality-of-life improvements! Makes GLVis behave a lot more like a standard Mac app, and works much more reliably than before. Dock icon and Ctrl-C are both working properly for me.

I haven't looked at the code in the PR, but from a user's perspective it's a big improvement!

lib/gl/types.cpp Outdated
float theta = atan2 (vy, vx);

#ifndef M_PI
const double M_PI = glm::pi<double>();
Copy link
Member

Choose a reason for hiding this comment

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

(minor) can this be constexpr?

}
if (XISelectEvents_(disp, wnd, &event_mask, 1) != Success)
{
cerr << "Failed to disable XInput on the current window!" << endl;
Copy link
Member

@tomstitt tomstitt Jul 7, 2021

Choose a reason for hiding this comment

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

should these error blocks also exit(EXIT_FAILURE) ? Or is XInput being enabled pretty minor? edit: i noticed glvis just has a lot of cases where errors are reported but they aren't necessarily fatal, it probably keeps things running in more cases which is good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think if we can't disable XInput extension events, it just means our event loop gets woken up more.

Copy link
Member

@tomstitt tomstitt left a comment

Choose a reason for hiding this comment

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

This is awesome, thanks @kanye-quest !

@camierjs
Copy link

camierjs commented Jul 7, 2021

Looks good to me too with Laghos.
Thank you again @kanye-quest for this PR!

@tzanio tzanio merged commit b513773 into master Jul 9, 2021
@tzanio tzanio deleted the threaded-server-dev branch July 9, 2021 20:20
@najlkin najlkin mentioned this pull request Jul 24, 2024
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.

6 participants