midori-browser / core

Midori Web Browser - a lightweight, fast and free web browser using WebKit and GTK+
https://www.midori-browser.org/
GNU Lesser General Public License v2.1
400 stars 67 forks source link

100% midori cpu usage, infinite loop key_press_event #370

Closed dennisnez closed 5 years ago

dennisnez commented 5 years ago

When I try to resize or move my midori window via my window manager's keyboard shortcuts, midori will somehow enter an infinite loop ... key_press_event in core/browser.vala will be endlessly called over and over again.

I can prevent this bug by commenting out the "if (base.key_press_event (event)) {}" block in that function, but then I lose midori's keyboard shortcuts.

Ie. the problem seems to be with "base.key_press_event (event)".

Another more repeatable symptom of this bug is with maps.google ... pressing the "+" key to zoom into the map will cause it to be repeatedly sent/"pressed", causing the map to endlessly zoom, until I force another tab open or somehow manage to take the focus of the keypresses away from the map.

Tested with webkit-gtk-2.24.4 and midori 7.0 and gtk+3-3.22.9/gtk+3-24.11, x86_64

dennisnez commented 5 years ago

A slightly better way of getting around this bug is by getting rid of that propagate_key_event() call, just before the base.key_press_event() call, in browser.vala's overrided key_press_event function. (And also getting rid of the "slash" and "Backspace" accels, which seem to be the only problematic ones in textfields/etc. https://pastebin.com/2sc0DmHv

In terms of the bug itself, by putting a delay in that function (and other printf debugging), I noticed that the bug only occurs after I click (focus) the main window/webkit area -- sending keypresses to the urlbar (which automatically has the first focus after loading) works fine. When pressing a key in the main window area, the same Gdk.EventKey's are endlessly repeated back, with the exact same gdk event timestamp. If I press a sequence of keys, eg. "a" then "b" then "c", they will be endlessly repeated back, all 3 of them.

kalikiana commented 5 years ago

We should probably consider this in #366. There was a fix related to CPU spikes like that due to event loops, which perhaps wasn't complete. I'd rather not remove key bindings, but the aforementioned PR attempts to handle that better.

dennisnez commented 5 years ago

This issue is a duplicate of issue #323, fixed with pull request #336. I'm not sure why Gentoo had such an outdated package. Removing the keybindings (eg. slash) isn't necessary.