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

Initial dragging of lines misses redraws after d99a133 on GTK 2 #148

Closed
whitequark opened this issue Jan 2, 2017 · 36 comments
Closed

Initial dragging of lines misses redraws after d99a133 on GTK 2 #148

whitequark opened this issue Jan 2, 2017 · 36 comments
Assignees
Milestone

Comments

@whitequark
Copy link
Contributor

E.g. try dragging a rectangle. While the mouse is moving no entities will be drawn correctly.

@Evil-Spirit please fix this ASAP

@whitequark whitequark added the bug label Jan 2, 2017
@whitequark whitequark added this to the 3.0 milestone Jan 2, 2017
@Evil-Spirit
Copy link
Collaborator

@whitequark, please, provide more information

@whitequark
Copy link
Contributor Author

@Evil-Spirit I have this instead of smooth dragging:
o

@Evil-Spirit
Copy link
Collaborator

@whitequark, hm. I have no such problem on Windows.
Do you have this after Rect creation and dragging it again?

@whitequark
Copy link
Contributor Author

Only during initial creation of rect and line. All other entities are fine.

@whitequark whitequark changed the title Dragging points is extremely slow after commit d99a133 Initial dragging of lines misses redraws after d99a133 Jan 2, 2017
@Evil-Spirit
Copy link
Collaborator

I have artifacts on initial dragging, but this is very old, it appears after we introduced "havePainted"

Evil-Spirit added a commit to Evil-Spirit/solvespace-master that referenced this issue Jan 2, 2017
@Evil-Spirit
Copy link
Collaborator

@whitequark
I have fixed same-looking issue on windows. Can you try it for linux?

@whitequark
Copy link
Contributor Author

@Evil-Spirit No, same thing.

@whitequark
Copy link
Contributor Author

I think maybe you aren't marking a group as dirty sometimes.

@Evil-Spirit
Copy link
Collaborator

@whitequark, Is InvalidateGraphics() actrually redraws all the window on linux?

@whitequark
Copy link
Contributor Author

Here's the code:

void InvalidateGraphics(void) {
    GW->get_widget().queue_draw();
}

void PaintGraphics(void) {
    GW->get_widget().queue_draw();
    /* Process animation */
    Glib::MainContext::get_default()->iteration(false);
}

InvalidateGraphics schedules a redraw, PaintGraphics schedules a redraw and immediately runs the message handling loop (just like WndProc) until all messages are processed.

Can you reproduce this in a VM?

@Evil-Spirit
Copy link
Collaborator

@whitequark, can you turn back
mouse.cpp:1391

        SS.MarkGroupDirty(c->group);
        SS.GenerateAll();

Probably PaintGraphics runs before GenerateAll

@whitequark
Copy link
Contributor Author

@Evil-Spirit That doesn't help. But I also found this only happens on GTK 2. So maybe this just means it's time to drop GTK 2 from SolveSpace 3, and fix any remaining bugs.

@whitequark whitequark changed the title Initial dragging of lines misses redraws after d99a133 Initial dragging of lines misses redraws after d99a133 on GTK 2 Jan 2, 2017
@whitequark whitequark assigned whitequark and unassigned Evil-Spirit Jan 2, 2017
@whitequark
Copy link
Contributor Author

Solved by killing GTK2 and removing various horrible hacks also.

@whitequark
Copy link
Contributor Author

I have artifacts on initial dragging, but this is very old, it appears after we introduced "havePainted"

Let's fix that too, what sort of artifact is that?

@Evil-Spirit
Copy link
Collaborator

When dragging new rect one of the line not matched in vertex. This is because redrawing before solving. This happens inside hit test function.

@whitequark
Copy link
Contributor Author

@Evil-Spirit There must be some other error, because with both of your fixes above, dragging of new rect still has the same issue on Linux.

@whitequark
Copy link
Contributor Author

@Evil-Spirit I've merged your Windows fix.

Evil-Spirit added a commit to Evil-Spirit/solvespace-master that referenced this issue Jan 3, 2017
@Evil-Spirit
Copy link
Collaborator

@whitequark, more fixes

@Evil-Spirit
Copy link
Collaborator

@whitequark, problem with mouse-move hovering happens again(viewport is not redrawing while moving over, just when mouse move stopped)

@whitequark
Copy link
Contributor Author

This fix you added makes no sense.

@Evil-Spirit
Copy link
Collaborator

@whitequark,
We have eliminated only PaintGraphics() call inside HitTestMakeSelection, so there is no place where PaintGraphics worked while mouse move events present in queue and takes a lot of time.

@Evil-Spirit
Copy link
Collaborator

@whitequark,
This is only windows problem

@whitequark
Copy link
Contributor Author

Then I will revert that commit, because your fix makes no sense, and after it PaintGraphics/InvalidateGraphics don't do what they claim to.

@Evil-Spirit
Copy link
Collaborator

@whitequark, Can you explain what does mean "don't do what they claim to"?
InvalidateGraphics before this just posts WM_PAINT message, PaintGraphics redraws immediately.
The things have worked before this way also works this way now (if WM_PAINT doesn't drew viewport it will be drawn using SS.later.paintGraphics, but never before GenerateAll as it can be done now)

@whitequark
Copy link
Contributor Author

whitequark commented Jan 4, 2017

And on GTK/Cocoa PaintGraphics redraws immediately. Any fix that makes the platforms diverge isn't the right fix, of course because then you and I will see different bugs.

Evil-Spirit added a commit to Evil-Spirit/solvespace-master that referenced this issue Jan 4, 2017
@Evil-Spirit
Copy link
Collaborator

@whitequark, OK, changed this

@whitequark
Copy link
Contributor Author

whitequark commented Jan 5, 2017

@Evil-Spirit That's much better! Let me see if this applies to Linux as well...

@whitequark
Copy link
Contributor Author

@Evil-Spirit Actually, I think your fix will create another problem. Try it on any case where hit testing is really slow.

@Evil-Spirit
Copy link
Collaborator

Evil-Spirit commented Jan 12, 2017

@whitequark,
I have tested it for big-big-big-woodworking-asm.slvs (where HitTestMakeSelection is really slow) and there is no problem for me (with using Evil-Spirit@6cdb9a3)

@whitequark whitequark added UI and removed UI labels Jan 14, 2017
@whitequark
Copy link
Contributor Author

I've figured out the problem. It has nothing to do with invalidation. Rather, it is because of ScheduleGenerateAll that never actually performs the generation if the queue is full of mouse move events (at least on Linux).

@Evil-Spirit
Copy link
Collaborator

@whitequark, Good. So how to fix this?

@whitequark
Copy link
Contributor Author

@Evil-Spirit Not sure. Maybe we need to rewrite the message handling loop on Linux to make it look like it does on Windows.

@whitequark
Copy link
Contributor Author

Fixed in master.

@Cimera42
Copy link

Cimera42 commented May 12, 2020

@Evil-Spirit I have this instead of smooth dragging:
o

I'm getting this exact issue on Windows when building the current master branch (e84fd46). I've tried building in Linux (WSL) with MinGW, and building on Windows with Visual Studio and MinGW.
I remember building back when Helix was added, and was getting the same issue.

Would love to know if anyone else is encountering this issue, and potential fixes. I've looked into the original fixes from above, but the file architecture has changed a lot since then.

@Cimera42
Copy link

Cimera42 commented May 12, 2020

Although I don't know the impacts of doing so, I've been able to get it working properly by removing the Invalidate() from mouse.cpp.

case Pending::DRAGGING_NEW_POINT:
    UpdateDraggedPoint(pending.point, x, y);
    HitTestMakeSelection(mp);
    SS.MarkGroupDirtyByEntity(pending.point);
    orig.mouse = mp;
    //Invalidate();
    break;

@whitequark
Copy link
Contributor Author

Thanks for the investigation. The fix doesn't look right to me in general, but the fact that it helps for your specific case is still useful to know. Please open a new issue to track this problem; I was under the impression that it's fixed, but looks like it either never was and wasn't detected by my tests, or it got broken somewhere since 2017.

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

No branches or pull requests

3 participants