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

Add playback scaling #65

Merged
merged 1 commit into from
Dec 13, 2017
Merged

Add playback scaling #65

merged 1 commit into from
Dec 13, 2017

Conversation

sabbaka
Copy link

@sabbaka sabbaka commented Nov 27, 2017

Use css transform property

@@ -620,6 +634,9 @@

/* Skip packets we don't output */
if (!pkt.is_io || !pkt.is_output) {
this.setState({cols: pkt.width, rows: pkt.height});
this.state.term.resize(pkt.width, pkt.height);
this._transform();
Copy link
Member

Choose a reason for hiding this comment

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

This will also execute on user input, which it shouldn't do. I think you need to rework this condition to only execute your part on !pkt.is_io.

@spbnick
Copy link
Member

spbnick commented Nov 30, 2017

Thank you, Kyrill. I tried this right now and it looks great. There is one problem, however: the terminal width seems to be constrained by less than the container width, if the browser view zoom is not 100%. Can anything be done about this? Here's a screenshot:
terminal_width_constrained

@sabbaka
Copy link
Author

sabbaka commented Nov 30, 2017 via email

@sabbaka
Copy link
Author

sabbaka commented Dec 5, 2017

In regards for problem with extra output - so, this strange symbols are logged which were not presented upon recording are added to output and are causing problems:
screenshot from 2017-12-05 16-07-41
screenshot from 2017-12-05 16-05-59
Those numbers 1566 and 1564 is difference between playback position and packet length ( because of this symbols ).
I've tested same code on Cockpit's side and updated tlog version ( build for Fedora 27 ) with mc - and there was this problem, though if I remove "throw" it works, but with this symbol breaking output.
If I use top to test resizing - playback works smoothly from end to start without problems.

@sabbaka
Copy link
Author

sabbaka commented Dec 5, 2017

As for matching size of the container, it was not a problem at all, only thing why it was appearing, that container has fluid width ( according to window size ) and I have had a static value of 630px, so now I've changed this to get actual wrapper's width, this will allow us in future to create full-screen or resizing of container features.

@sabbaka
Copy link
Author

sabbaka commented Dec 6, 2017

https://youtu.be/9EAN6Id1YxE
So, here is what I have for now - controls are working, but content is not centered after zooming in/out - that's because I've to use tricky way to center it inside the above container.
I've put it as a separate commit also for more simple review and also I've changed a bit work with setState - I've tried to decrease amount of calls for only one, but I don't have any metrics if it actually has any effect on performance.

@sabbaka
Copy link
Author

sabbaka commented Dec 6, 2017

Also, I've forgot to add one more detail - I've had the idea to add feature as a hand scrolling - for example - you zoomed in and you would just use drag'n'drop to move through content and not the scrollbars, but now I'm not sure if that should be there, because that will remove ability to select text and copy it! But it is possible to create some sort of switch ( button ) between regular cursor to work with text and drag'n'drop.

@spbnick
Copy link
Member

spbnick commented Dec 6, 2017

Niice, this feels much better, and it seems the issue with non-100% zoom levels is gone. Yes, I think we need to fix the non-centered zoom-in/out as it's confusing. How about we merge the part which keeps the terminal within bounds first, and then work on scrolling/zooming/panning? That way we'll have something working merged already.

Yeah, "panning" can be done with a button, although it wouldn't be very convenient to use. Perhaps we can do the button (like http://fontawesome.io/icon/hand-paper-o/), and add a hotkey for turning it on or off, and/or a hotkey which would enable panning while pressed (i.e. hold the key and drag the screen, otherwise select).

One thing that I keep noticing is that intermediate window resizes seem to disappear and window jumps through them when skipping, unless there's I/O. Perhaps the main playback routine needs fixing. Can you check that?

Regarding the extra characters, could you please provide me with the original logs, where that reproduces? You can use the journalctl command to dump the messages for the session using the same matches Cockpit uses when playing back the session. I'll try to see where there is a problem in encoding/decoding.

@spbnick
Copy link
Member

spbnick commented Dec 6, 2017

Oh, and another thing: the "zoom to fit" icon seems a bit confusing to me. Do you think we can draw and/or use something like a "square under a lens" icon? E.g. something like these: https://www.iconfinder.com/search/?q=zoom+fit
Or it would be breaking our pattern of using Font Awesome?

@sabbaka
Copy link
Author

sabbaka commented Dec 6, 2017

Yes, for now, if you will play or skip frames zoom levels will be switched back to match container ( not preserving zoom levels basically ).
This is "broken" session:
mc_broken_session_dump.txt

@sabbaka
Copy link
Author

sabbaka commented Dec 6, 2017

I think we should stick with font awesome to keep overall style. I'll add hotkeys and split commits in two - for playback scaling and for controls

@sabbaka
Copy link
Author

sabbaka commented Dec 7, 2017

I've separated commits and now in this PR it's only commit for scaling without buttons.

Copy link
Member

@spbnick spbnick left a comment

Choose a reason for hiding this comment

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

Thank you, Kyrill! This looks alright aside from the inline comments.

However, I notice that the playback area gets a scrollbar sometimes, which covers parts of the terminal, especially at extreme proportions. Can that be fixed somehow?

@@ -473,6 +474,8 @@
paused: true,
/* Speed exponent */
speedExp: 0,
scale: 1,
container_width: 630,
Copy link
Member

Choose a reason for hiding this comment

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

Could you please keep values aligned here?

_transform(width, height) {
var relation = Math.min(
this.state.container_width / this.state.term.element.offsetWidth,
290 / this.state.term.element.offsetHeight
Copy link
Member

Choose a reason for hiding this comment

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

What is this 290? Could you please use a constant with a name which would give a clue instead?

@@ -620,6 +639,8 @@

/* Skip packets we don't output */
if (!pkt.is_io || !pkt.is_output) {
this.state.term.resize(pkt.width, pkt.height);
this._transform(pkt.width, pkt.height);
Copy link
Member

Choose a reason for hiding this comment

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

This is also being called on "input" packets, not only on "window" packets. You're not hitting this now, because input is not recorded by default. Please fix.

Copy link
Member

Choose a reason for hiding this comment

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

Essentially, instead of adding code here, the if condition should be changed to pkt.is_io && !pkt.is_output, and the code added instead after the "Output the packet" comment below, branching on output/window packet type. This would also fix the timing issues with window resizing.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I'm doing this now. Just missed this problem before. Thanks for clarifying, I was about to use just if (pkt.is_output)

Copy link
Author

Choose a reason for hiding this comment

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

I've made a bit different change, not sure if it's okay, but my implementation of your provided idea did not work, let's also discuss this tomorrow, probably I'm missing something.

@spbnick
Copy link
Member

spbnick commented Dec 7, 2017

I think that there's value in a blinking cursor, and we can discuss that, but let's not lump that change with this one.

@sabbaka sabbaka force-pushed the scribery branch 3 times, most recently from c2ec90f to 9da7540 Compare December 8, 2017 12:34
@sabbaka
Copy link
Author

sabbaka commented Dec 8, 2017

I've removed removal of blinking cursor and added ours together if/else fix from meeting.

@spbnick
Copy link
Member

spbnick commented Dec 11, 2017

I took a look at this today and it feels much better. However, I see that sometimes window resize and repaint play back with a huge delay between them. I'm not sure where that comes from. Will investigate tomorrow.

@spbnick
Copy link
Member

spbnick commented Dec 12, 2017

@sabbaka, I still see the old resizing code in the commit, not the one we arrived at on our meeting. Have you forgotten to commit/push something, perhaps?

@sabbaka
Copy link
Author

sabbaka commented Dec 12, 2017 via email

@sabbaka
Copy link
Author

sabbaka commented Dec 12, 2017

Code should be fine now, it seems that I've just forgot to push.

Copy link
Member

@spbnick spbnick left a comment

Choose a reason for hiding this comment

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

Apart from the three inline style comments, this looks and works great! Thank you, Kyrill.

@@ -473,8 +474,12 @@
paused: true,
/* Speed exponent */
speedExp: 0,
scale: 1,
containerWidth: 630,
Copy link
Member

Choose a reason for hiding this comment

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

Please align the new values with the rest.

@@ -532,7 +537,7 @@
cols: this.state.cols,
rows: this.state.rows,
screenKeys: true,
useStyle: true
useStyle: true,
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this unnecessary change.

@@ -617,9 +637,8 @@
this.awaitPacket();
return;
}

Copy link
Member

Choose a reason for hiding this comment

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

Please remove this unnecessary change.

@sabbaka
Copy link
Author

sabbaka commented Dec 12, 2017

I've made changes, but I'm not sure if I understand how to align correctly.

@spbnick
Copy link
Member

spbnick commented Dec 12, 2017

Thank you. Just make them all appear on the same column. Like this:

    cols:           80,
    rows:           25,
    title:          _("Player"),
    term:           null,
    paused:         true,
    /* Speed exponent */
    speedExp:       0,
    containerWidth: 630,
    scale:          1

Use css transform property
@spbnick spbnick merged commit 8579db4 into Scribery:scribery Dec 13, 2017
@spbnick
Copy link
Member

spbnick commented Dec 13, 2017

Thanks a lot, looks and works great! Can you do a demo on today's meeting?

Another thing: could you please leave a comment when you're done fixing up things in response to review? I just don't get any updates from GitHub when you're force-pushing over a commit, without adding a new one. And even when you add a new one, it would be great to get a comment from you saying you're done.

@sabbaka
Copy link
Author

sabbaka commented Dec 13, 2017

Yes, I will do the demo.
Pardon, just missed that yesterday.

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.

2 participants