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

Minihtml popup flickers when updating. #3107

Closed
deathaxe opened this issue Nov 25, 2019 · 14 comments
Closed

Minihtml popup flickers when updating. #3107

deathaxe opened this issue Nov 25, 2019 · 14 comments

Comments

@deathaxe
Copy link
Collaborator

Description

Calling view.show_panel() sequencially in order to update the content, size or positon of a popup causes it to shortly disapear. It feels noisy especially in situations the popup is tight to key strokes or changing selections.

The recently announced Emmet 2 plugin is a very prominent example for that issue as it displays a preview popup right below the typed text.

Quickly typing an appreviation causes the popup to heavily flicker.

Related with #3099

Steps to reproduce

  1. Open ST vanilla
  2. Create a plugin with the following code
   import sublime_plugin
   
   
   class PopupListener(sublime_plugin.EventListener):
   
       def on_selection_modified(self, view):
           view.show_popup("Hello World", location=view.sel()[0].begin())
  1. Start typing
  2. See how the popup flickers each time its position is updated.

Expected behavior

Move and/or resize the minihtml popup window seemlessly.

Actual behavior

The popup window disapears for some millisecons each time it is to be updated or moved via view.show_popup() API function.

Animation

Environment

  • Build: 3xxx and 4055
  • Operating system and version: Windows 10 x64 1903
@jrappen
Copy link
Contributor

jrappen commented Nov 25, 2019

/cc @sergeche

@sergeche
Copy link

More flickering caused by *_async version of event listeners: tried to use them to reduce work load on every update but flickering was too annoying. It also happens with phantoms (see abbreviations in CSS)

@deathaxe
Copy link
Collaborator Author

@jskinner added a fix for that in Sublime Merge during the last dev cycle. Hope it would find its way over to Sublime Text.

@FichteFoll
Copy link
Collaborator

For now, you should probably resort to holding back changes with a timeout and only update every x ms.

@daveleroy
Copy link

This can be worked around right now using update_popup if you do not need to reposition the popup and your popup is still visible.

If you are creating a phantom to replace an existing one you should do it in the main sublime thread (if you generate your html on a background thread use sublime.set_timeout) otherwise you will get flickering when the phantom is replaced. (fixed? version > 4000)

@jrappen
Copy link
Contributor

jrappen commented Nov 26, 2019

@deathaxe
Copy link
Collaborator Author

... need to reposition the popup ...

That's the root cause of raising this issue.

@sergeche
Copy link

It seems like the problem is that popup automatically hides on each update (at least in my case) so I can’t just update its contents. Maybe because I use view.add_regions() on every update?

@jskinner
Copy link
Member

FWIW the next build of S4 will have an additional flag, sublime.KEEP_ON_SELECTION_MODIFIED, which will keep a popup open when the selection changes

@deathaxe
Copy link
Collaborator Author

deathaxe commented Dec 1, 2019

Just retried my debug snippet with the new flag on ST4057. Unfortunatelly it seems to have no effect on Windows.

This is my updated debug code:

import sublime
import sublime_plugin


class PopupListener(sublime_plugin.EventListener):

    def on_selection_modified(self, view):
        try:
            view.show_popup(
                "Hello World",
                flags=sublime.KEEP_ON_SELECTION_MODIFIED,
                location=view.sel()[0].begin()
            )
        except IndexError:
            pass

@jskinner
Copy link
Member

jskinner commented Dec 1, 2019

That's right, it won't reduce flickering if you're calling view.show_popup(), but it will allow view.update_popup() to be used in more circumstances.

True flicker free updating of the popup under all circumstance will require using 'virtual' popups, which would be constrained to the window area, as I haven't found a way to change both a window position and content in a synchronous manner under X11. I'm planning on experimenting with this approach.

@deathaxe
Copy link
Collaborator Author

deathaxe commented Dec 2, 2019

Thanks for the info and looking into it. I guess it is the same for auto-completion popups then?

evandrocoan added a commit to evandrocoan/AmxxEditor that referenced this issue Jun 6, 2020
@wbond
Copy link
Member

wbond commented Jul 10, 2020

Build 4075 moves all popups from child windows to child controls of the main window. I believe this should improve this issue.

Do you see any improvement @deathaxe?

@deathaxe
Copy link
Collaborator Author

It's moving smoothly.

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

7 participants