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

Topic/refactor server status #1547

Closed
wants to merge 61 commits into from
Closed

Conversation

telephon
Copy link
Member

This PR is still being developed, but it shouldn't break and can be tested.

This fixes #774 and fixes #889: instead of just assuming that the server is dead, it is taken to be unresponsive. It also fixes #1484.

It factors out all statusWatcher and recording functionality to a separate class (ServerStatusWatcher and Recorder). This branch also implements the updating of recording display in the IDE.

There is some more refactoring, in the server code itself, the Volume class, and also the allocation of buffers in Buffer.

While I took care to keep the old interface, this refactor may break code that relies on instance variables in Server, these problems are usually easy to solve, by writing, e.g. this.avgCPU instead of avgCPU.

Some refactoring of the serverRunning_ method. This method is now really used to set the state if known. If unknown, like from the aliveThread, we call updateRunningState instead. This method will not change serverRunning if false, but will mark the server as unresponsive. Only if we quit the server from sclang explicitly, we call serverRunning_ directly.
…t for them to close down. They won't reply anyway.
…is for efficiency to keep at least serverRunning in Server, because this method is called all the time
@telephon telephon self-assigned this Jun 15, 2015
@telephon telephon added this to the 3.8 milestone Jun 15, 2015
aliveThread
}

/* backward compatibility */
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't refer to this as "backward compatibility". the statusWatcher should be considered a private object and people should not be encouraged to use it or to think that its the new way to do things.

these methods are the correct way IMO to expose the api. so I suggest removing the "backward" comment

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes. I was wondering whether it is OK to have the getter to the watcher. I used it once:

*resumeThreads {
        set.do { |server| server.statusWatcher.resumeThread }
    }

I could of course add a method to Server that isolates it. What do you think?

@crucialfelix
Copy link
Member

useful to clean up Server, its a mess. I would also move the gui into a separate class, but please call it ServerGUI and not ServerGui as there is already one in crucial-library.

agree: 3.8

Because CmdPeriod calls resumeThreads, all registered servers, if booted or not, have aliveThreads. This patch fixes that impolite misbehavior.
@telephon
Copy link
Member Author

useful to clean up Server, its a mess. I would also move the gui into a separate class, but please call it ServerGUI and not ServerGui as there is already one in crucial-library.

OK, that is a good idea. I'll also write a Recorder, which can be separately refined.

@telephon
Copy link
Member Author

telephon commented Jul 8, 2015

@timblechmann I have tried to correctly implement pauseRecording in the IDE, which turned out to be difficult. After a couple of days trying I have over time resolved many issues, but still it's not doing what it should - maybe you could have a look? The PauseRecording menu entry shouldn't trigger the sclang message all the time, e.g.

@telephon
Copy link
Member Author

telephon commented Jul 8, 2015

@crucialfelix uh, yes, no big hurry!

@timblechmann
Copy link
Contributor

@crucialfelix https://github.com/crucialfelix

I would also move the gui into a separate class, but please call it
ServerGUI and not ServerGui as there is already one in crucial-library.

It would be good to do a ServerView class that uses Qt properly. But I
am not very patient at this, maybe this could be fixed later. The code
is messy currently, but at least separate from the rest in
|ServerPlusGui|, and only three methods, so we can live with it in the
meantime.

do use Qt "properly" one should probably implement a QML view and move
all the gui code to qml.
if i understand jakob's qtcollider architecture correctly, it should be
quite straight-forward to implement a sc/qml bridge using
doesNotUnderstand to map selectors to qml properties ...

then one would have a gui system with modern features (delarative,
constraint-driven layouts, 60hz, vsync driven animations)

btw, @telephon: it makes sense to split a PR of 52 commit to functional
units, which can be reviewed and merged individually ...

@telephon
Copy link
Member Author

telephon commented Jul 8, 2015

btw, @telephon: it makes sense to split a PR of 52 commit to functional units, which can be reviewed and merged individually ...

Yes, agreed. Unfortunately, it's a big refactoring and the commits all build on top of each other – so I'm not sure of how to do this. I've reduced and reshuffled as much as possible with rebase -i but there is a limit to what can you do here. I may be missing a trick here though.

Maybe it would have been even easier to just make one commit that removes the whole Sever class and then add things step by step ...

@telephon
Copy link
Member Author

telephon commented Jul 8, 2015

do use Qt "properly" one should probably implement a QML view and move all the gui code to qml.

yes, very much so. Maybe the best way to specify views would then be to embed QML in sclang directly as a string? It is very readable and adequately representing its objects in sclang would be overly complicated.

@scztt
Copy link
Contributor

scztt commented Jul 8, 2015

do use Qt "properly" one should probably implement a QML view and move all the gui code to qml.

yes, very much so. Maybe the best way to specify views would then be to embed QML in sclang directly >as a string? It is very readable and adequately representing its objects in sclang would be overly >complicated.

This would be cool for sure, and is probably a better match for the state-of-the-art of Qt - but, I'm unclear what the concrete gains would be... Doing even complex layouts in SC now is, for the most part, very simple and clear. Declarative layouts are powerful, but are there GUI-building tasks in SC that are currently difficult / impossible because of limitations in the layout implementation? Do we have bugs that would be fixed by vsync animation? Are there QML widgets that would be a big improvement to existing options in SC?

I don't mean to sound too skeptical (I'd love to hear other benefits of qml), but in the list of features that would have a big user-impact when UI-building in SuperCollider, I think it's down the list (refactoring .action's to a proper event-based / signal-slot pattern? exposing unexposed Qt functionality on existing widgets? WYSIWYG layout-ing? SynthDef graph display? Improved scopes? Better high-DPI & multitouch support?)

@scztt
Copy link
Contributor

scztt commented Jul 8, 2015

@telephon, re commits: This seems like a fine granularity? Reading through, I don't see a huge benefit to testing this in too many separate pieces. At that point, the only real impact of the commit organization is what you see in blame - which, as it's structured now, is useful enough. The one thing I would say is - given the amount of functional change, a unit test that defines how the Server API's should work (especially in terms of notifications) should absolutely be a part of this.

@timblechmann
Copy link
Contributor

    do use Qt "properly" one should probably implement a QML view
    and move all the gui code to qml.

yes, very much so. Maybe the best way to specify views would then be
to embed QML in sclang directly >as a string? It is very readable
and adequately representing its objects in sclang would be overly
>complicated.

it would be possible to pass the qml code as string or as a QUrl (which
could be local or remote files)

This would be cool for sure, and is probably a better match for the
state-of-the-art of Qt - but, I'm unclear what the concrete gains would
be... Doing even complex layouts in SC now is, for the most part, very
simple and clear. Declarative layouts are powerful, but are there
GUI-building tasks in SC that are currently difficult / impossible
because of limitations in the layout implementation? Do we have bugs
that would be fixed by vsync animation? Are there QML widgets that would
be a big improvement to existing options in SC?

  • Pen is slow
  • animations need to be done in sclang code (no vsynced 60 hz)
  • guis in qml are declarative, much less update bugs
  • sc's current guis have hardcoded pixel sizes all over the place, which
    horribly breaks on linux with variable-sized DPI, where you end up
    having cropped texts ...
  • gui building is currently slow and error-prone ... many guis come from
    a time before constraint-based layouting was invented
  • one could even use opengl shaders embedded in qml embedded in sclang

just a few thoughs ... jakob was already proposing this years ago ...

@crucialfelix
Copy link
Member

um ... shouldn't you people be making music ?

@timblechmann
Copy link
Contributor

i was always surprised that once you write code people think that you are not a musician ...

@crucialfelix
Copy link
Member

that's not what I meant. I was referring to the endless amount of discussion about GUI that happens in supercollider development.

@muellmusik
Copy link
Contributor

i was always surprised that once you write code people think that you are not a musician ...

And the opposite! :-)

@telephon
Copy link
Member Author

telephon commented Jul 9, 2015

I have to say that it would simplify a lot if we could do something like this.

  • Pen is slow * animations need to be done in sclang code (no vsynced 60 hz)

This is a major issue, I think: it is also low resolution. Many people are using sc to do graphics with their music, or well, visual music.

@scztt
Copy link
Contributor

scztt commented Jul 10, 2015

I'd love to see a proof-of-concept QML implementation of something that's better suited to QML than regular SC. Not sure what a good candidate is - maybe an animated version of Plot? I'd love to see what the performance difference is, as well as how easy it is to get data connected to the requisite drawing code in a SC vs QML version. It would be a good use-case for driving (and justifying) QML features.

@scztt
Copy link
Contributor

scztt commented Jul 10, 2015

This is a major issue, I think: it is also low resolution. Many people are using sc to do graphics with their music, or well, visual music.

What do you mean by low resolution? Meaning, high dpi bugs, or something else?

@crucialfelix
Copy link
Member

there's this: https://github.com/jleben/quickcollider

On Fri, Jul 10, 2015 at 3:34 AM scztt notifications@github.com wrote:

I'd love to see a proof-of-concept QML implementation of something that's
better suited to QML than regular SC. Not sure what a good candidate is -
maybe an animated version of Plot? I'd love to see what the performance
difference is, as well as how easy it is to get data connected to the
requisite drawing code in a SC vs QML version. It would be a good use-case
for driving (and justifying) QML features.


Reply to this email directly or view it on GitHub
#1547 (comment)
.

@telephon
Copy link
Member Author

This is a major issue, I think: it is also low resolution. Many people are using sc to do graphics with their music, or well, visual music.

What do you mean by low resolution? Meaning, high dpi bugs, or something else?

On retina screens, aliasing is broken and looks bad, even number boxes. I once added an issue, but couldn't find it anymore now.

bootNotifyFirst was implemented in a way that seemed not to work properly. This is also undocumented, so it may need someone who knows how it was supposed to work.

This is why I commented it out and factored out a clearer message for server.
@miguel-negrao
Copy link
Member

then one would have a gui system with modern features (delarative, constraint-driven layouts, 60hz, vsync driven animations)

Possibly I already mentioned this, in which case I apologize for re-posting, just mentioning in the interest of comparing approaches. I have a declarative system implemented in FPLib which can be used for GUI time-dependent logic. It is similar to http://elm-lang.org/. I also implemented a declarative Pen interface, although it probably makes Pen drawing even slower. Possibly QML + an FRP system on sclang's side could be interesting, although FRP causes some cognitive dissonance to imperative programmers which might be insurmountable.

https://github.com/miguel-negrao/FPLib/blob/master/Examples/FRP/ENdef-jitlib_style.scd
https://github.com/miguel-negrao/FPLib/blob/master/Examples/FRP/mouse_and_drawing.scd

@telephon
Copy link
Member Author

Closing it, moving to branch refactoring-server-clean

@telephon telephon closed this Sep 16, 2015
@telephon telephon deleted the topic/refactor-server-status branch September 16, 2015 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants