cpbotha / nvpy

Simplenote syncing note-taking application, inspired by Notational Velocity and ResophNotes, but uglier and cross-platformerer.
Other
849 stars 114 forks source link

Random freezes #180

Closed volt4ire closed 5 years ago

volt4ire commented 5 years ago

Nvpy often randomly stops responding to mouse and keyboard input, despite its logs (see below) not indicating any issues. I tried removing the .nvpy directory but the issue still persists. I am running Kubuntu 19.04 and nvpy version 1.2.1. Can you please help me address this? Thanks!

2019-05-03 07:28:55,348 - DEBUG - Starting full sync. 2019-05-03 07:28:55,453 - DEBUG - Retrieving full note list from server, could take a while. 2019-05-03 07:28:58,472 - DEBUG - Retrieved full note list from server. 2019-05-03 07:28:58,587 - DEBUG - Deleted note 0. 2019-05-03 07:41:41,185 - DEBUG - nvpy logging initialized 2019-05-03 07:41:41,185 - DEBUG - config read from ['/home/rwbarat/.nvpy.cfg'] 2019-05-03 07:41:41,780 - DEBUG - Starting full sync. 2019-05-03 07:41:41,946 - DEBUG - Retrieving full note list from server, could take a while. 2019-05-03 07:41:43,863 - DEBUG - Retrieved full note list from server. 2019-05-03 07:41:43,975 - DEBUG - Deleted note 0.

yuuki0xff commented 5 years ago

Could you run nvpy on terminal? Maybe nvpy displays traceback or pdb (python debugger) prompt. When the pdb prompt is displayed, please type bt, l (lower case of L) and p <variable_name> to investigate the crash cause.

yuuki0xff commented 5 years ago

I created a commit (6ef839a5d29816df18ac5ece1e93aaf1ada37d33) on the master branch. It may help to debug. Please try it.

yuuki0xff commented 5 years ago

I found a freeze bug. This issue seems to be related to your reported issue.

Reproduction procedure:

  1. Disconnect from the internet.
  2. Create new notes or modify some notes.
  3. Make sure that all notes have been saved.
  4. Stop nvpy.
  5. Start nvpy. Nvpy will freeze.

nvpy version: 6ef839a5d29816df18ac5ece1e93aaf1ada37d33 (patched)

# nvpy.patch
diff --git a/nvpy/view.py b/nvpy/view.py
index e494bff..4cc96c4 100644
--- a/nvpy/view.py
+++ b/nvpy/view.py
@@ -453,7 +453,12 @@ class NotesList(tk.Frame):

         title = utils.get_note_title(note)
         tags = note.get('tags')
-        modifydate = float(note.get('modifydate'))
+        try:
+            modifydate = float(note.get('modifydate'))
+        except:
+            print('Nvpy crashed by this note')
+            print(note)
+            raise
         pinned = utils.note_pinned(note)
         createdate = float(note.get('createdate'))
         self.note_headers.append((title, tags, modifydate, pinned, createdate))
# stdout/stderr
Nvpy crashed by this note
{u'tags': [], 'deleted': False, 'shareURL': '', u'syncdate': 0, 'systemTags': [], u'content': u'new note', u'savedate': 1557038850.457084, 'publishURL': '', 'modificationDate': 1557038808.275074, 'creationDate': 1557038807.275033}

.... omitted ....
# ~/.nvpy/nvpy.log
2019-05-05 15:46:44,859 - DEBUG - nvpy logging initialized
2019-05-05 15:46:44,860 - DEBUG - config read from ['/home/yuuki/.nvpy.cfg']
2019-05-05 15:46:45,046 - DEBUG - Starting full sync.
2019-05-05 15:46:45,049 - ERROR - Could not get note list from server: <urlopen error [Errno -3] Temporary failure in name resolution>
2019-05-05 15:46:45,061 - DEBUG - Retrieving full note list from server, could take a while.
2019-05-05 15:46:49,147 - DEBUG - title "new note" resync
2019-05-05 15:46:53,144 - DEBUG - Sending new note (local key a44366f2acad2650008f036948153f) to server.
2019-05-05 15:46:55,168 - DEBUG - Sending new note (local key a44366f2acad2650008f036948153f) to server.
2019-05-05 15:47:30,249 - DEBUG - nvpy logging initialized
2019-05-05 15:47:30,249 - DEBUG - config read from ['/home/yuuki/.nvpy.cfg']
2019-05-05 15:47:30,472 - DEBUG - Starting full sync.
2019-05-05 15:47:30,475 - ERROR - Sync step 1 error - Could not update note a44366f2acad2650008f036948153f to server: <urlopen error [Errno -3] Temporary failure in name resolution>
2019-05-05 15:47:30,485 - CRITICAL - 
ERROR: An unexpected error occurred.
Thread(ident=139823599474496, name=MainThread)
Traceback (most recent call last):
  File "/home/yuuki/nvpy/nvpy/debug.py", line 31, in wrapper
    return fn(*args, **kwargs)
  File "/home/yuuki/nvpy/nvpy/view.py", line 1847, in observer_notes_list
    self.set_notes(notes_list_model.list)
  File "/home/yuuki/nvpy/nvpy/view.py", line 1949, in set_notes
    self.notes_list.append(o.note, utils.KeyValueObject(tagfound=o.tagfound))
  File "/home/yuuki/nvpy/nvpy/view.py", line 457, in append
    modifydate = float(note.get('modifydate'))
TypeError: float() argument must be a string or a number

Other threads:
Thread(ident=139823599474496, name=MainThread)
  File "/home/yuuki/.local/bin/nvpy", line 11, in <module>
    load_entry_point('nvpy', 'gui_scripts', 'nvpy')()
  File "/home/yuuki/nvpy/nvpy/nvpy.py", line 859, in main
    controller.main_loop()
  File "/home/yuuki/nvpy/nvpy/nvpy.py", line 407, in main_loop
    self.view.main_loop()
  File "/home/yuuki/nvpy/nvpy/view.py", line 1850, in main_loop
    self.root.mainloop()
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1138, in mainloop
    self.tk.mainloop(n)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
    return self.func(*args)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 599, in callit
    func(*args)
  File "/home/yuuki/nvpy/nvpy/nvpy.py", line 404, in poll_notifies
    self.notes_db.handle_notifies()
  File "/home/yuuki/nvpy/nvpy/utils.py", line 238, in handle_notifies
    o(self, evt_type, evt)
  File "/home/yuuki/nvpy/nvpy/debug.py", line 31, in wrapper
    return fn(*args, **kwargs)
  File "/home/yuuki/nvpy/nvpy/nvpy.py", line 421, in observer_notes_db_sync_full
    self.view.refresh_notes_list()
  File "/home/yuuki/nvpy/nvpy/view.py", line 1031, in refresh_notes_list
    self.set_search_entry_text(self.get_search_entry_text())
  File "/home/yuuki/nvpy/nvpy/view.py", line 1089, in set_search_entry_text
    self.search_entry_var.set(text)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 274, in set
    return self._tk.globalsetvar(self._name, value)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
    return self.func(*args)
  File "/home/yuuki/nvpy/nvpy/view.py", line 1678, in handler_search_entry
    utils.KeyValueObject(value=self.search_entry_var.get()))
  File "/home/yuuki/nvpy/nvpy/utils.py", line 220, in notify_observers
    o(self, evt_type, evt)
  File "/home/yuuki/nvpy/nvpy/debug.py", line 31, in wrapper
    return fn(*args, **kwargs)
  File "/home/yuuki/nvpy/nvpy/nvpy.py", line 672, in observer_view_change_entry
    self.notes_list_model.set_list(nn)
  File "/home/yuuki/nvpy/nvpy/nvpy.py", line 247, in set_list
    self.notify_observers('set:list', None)
  File "/home/yuuki/nvpy/nvpy/utils.py", line 220, in notify_observers
    o(self, evt_type, evt)
  File "/home/yuuki/nvpy/nvpy/debug.py", line 45, in wrapper
    all_threads=format_all_tracebacks(),
  File "/home/yuuki/nvpy/nvpy/debug.py", line 17, in format_all_tracebacks
    stack = traceback.format_stack(frame)
Thread(ident=139823551530752, name=Thread-1)
  File "/usr/lib/python2.7/threading.py", line 774, in __bootstrap
    self.__bootstrap_inner()
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/yuuki/nvpy/nvpy/debug.py", line 31, in wrapper
    return fn(*args, **kwargs)
  File "/home/yuuki/nvpy/nvpy/notes_db.py", line 929, in worker_save
    o = self.q_save.get()
  File "/usr/lib/python2.7/Queue.py", line 168, in get
    self.not_empty.wait()
  File "/usr/lib/python2.7/threading.py", line 340, in wait
    waiter.acquire()
Thread(ident=139823543138048, name=Thread-2)
  File "/usr/lib/python2.7/threading.py", line 774, in __bootstrap
    self.__bootstrap_inner()
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/yuuki/nvpy/nvpy/debug.py", line 31, in wrapper
    return fn(*args, **kwargs)
  File "/home/yuuki/nvpy/nvpy/notes_db.py", line 955, in worker_sync
    o = self.q_sync.get()
  File "/usr/lib/python2.7/Queue.py", line 168, in get
    self.not_empty.wait()
  File "/usr/lib/python2.7/threading.py", line 340, in wait
    waiter.acquire()
# ~/.nvpy/a44366f2acad2650008f036948153f.json
{
  "modifydate": 1557038808.275074, 
  "tags": [], 
  "createdate": 1557038807.275033, 
  "syncdate": 0, 
  "content": "new note", 
  "savedate": 0
}
volt4ire commented 5 years ago

Could you run nvpy on terminal? Maybe nvpy displays traceback or pdb (python debugger) prompt. When the pdb prompt is displayed, please type bt, l (lower case of L) and p <variable_name> to investigate the crash cause.

Thanks for getting back to me so quickly! I upgraded to the new dev version (via git+https://github.com/cpbotha/nvpy.git#egg=nvpy). Here's the ouput from the terminal after nvpy freezes 20 minutes or so into normal use. I tried entering bt, l (lower case of L) and p into the terminal but nothing happened

$ nvpy
ERROR: An unexpected error occurred.
Thread(ident=140001508566848, name=MainThread)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/nvpy/debug.py", line 31, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/nvpy/nvpy.py", line 633, in observer_view_select_note
self.select_note(evt.sel)
File "/usr/local/lib/python2.7/dist-packages/nvpy/nvpy.py", line 809, in select_note
self.view.set_note_data(note)
File "/usr/local/lib/python2.7/dist-packages/nvpy/view.py", line 1903, in set_note_data
self.text_note.insert(tk.END, note['content'])
File "/usr/local/lib/python2.7/dist-packages/nvpy/view.py", line 115, in new_insert
self.orig_insert(*args)
File "/usr/local/lib/python2.7/dist-packages/nvpy/view.py", line 94, in __call__
return self.tk_call(self.orig_and_name + args)
TclError: character U+1f63b is above the range (U+0000-U+FFFF) allowed by Tcl
Other threads:
Thread(ident=140001508566848, name=MainThread)
File "/usr/local/bin/nvpy", line 11, in <module>
load_entry_point('nvpy==1.2.2.dev0', 'gui_scripts', 'nvpy')()
File "/usr/local/lib/python2.7/dist-packages/nvpy/nvpy.py", line 859, in main
controller.main_loop()
File "/usr/local/lib/python2.7/dist-packages/nvpy/nvpy.py", line 407, in main_loop
self.view.main_loop()
File "/usr/local/lib/python2.7/dist-packages/nvpy/view.py", line 1845, in main_loop
self.root.mainloop()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1138, in mainloop
self.tk.mainloop(n)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
return self.func(*args)
File "/usr/local/lib/python2.7/dist-packages/nvpy/view.py", line 1673, in handler_search_entry
utils.KeyValueObject(value=self.search_entry_var.get()))
File "/usr/local/lib/python2.7/dist-packages/nvpy/utils.py", line 220, in notify_observers
o(self, evt_type, evt)
File "/usr/local/lib/python2.7/dist-packages/nvpy/debug.py", line 31, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/nvpy/nvpy.py", line 679, in observer_view_change_entry
self.view.select_note(0)
File "/usr/local/lib/python2.7/dist-packages/nvpy/view.py", line 1047, in select_note
self.notes_list.select(idx, silent)
File "/usr/local/lib/python2.7/dist-packages/nvpy/view.py", line 646, in select
self.event_generate('<<NotesListSelect>>')
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1518, in event_generate
self.tk.call(args)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1550, in __call__
return self.func(*args)
File "/usr/local/lib/python2.7/dist-packages/nvpy/view.py", line 948, in cmd_notes_list_select
self.notify_observers('select:note', utils.KeyValueObject(sel=sidx))
File "/usr/local/lib/python2.7/dist-packages/nvpy/utils.py", line 220, in notify_observers
o(self, evt_type, evt)
File "/usr/local/lib/python2.7/dist-packages/nvpy/debug.py", line 45, in wrapper
all_threads=format_all_tracebacks(),
File "/usr/local/lib/python2.7/dist-packages/nvpy/debug.py", line 17, in format_all_tracebacks
stack = traceback.format_stack(frame)
Thread(ident=140001456547584, name=Thread-1)
File "/usr/lib/python2.7/threading.py", line 774, in __bootstrap
self.__bootstrap_inner()
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/nvpy/debug.py", line 31, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/nvpy/notes_db.py", line 929, in worker_save
o = self.q_save.get()
File "/usr/lib/python2.7/Queue.py", line 168, in get
self.not_empty.wait()
File "/usr/lib/python2.7/threading.py", line 340, in wait
waiter.acquire()
Thread(ident=140001447892736, name=Thread-2)
File "/usr/lib/python2.7/threading.py", line 774, in __bootstrap
self.__bootstrap_inner()
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/nvpy/debug.py", line 31, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/nvpy/notes_db.py", line 955, in worker_sync
o = self.q_sync.get()
File "/usr/lib/python2.7/Queue.py", line 168, in get
self.not_empty.wait()
File "/usr/lib/python2.7/threading.py", line 340, in wait
waiter.acquire()
> /usr/local/lib/python2.7/dist-packages/nvpy/view.py(94)__call__()
-> return self.tk_call(self.orig_and_name + args)
(Pdb)
yuuki0xff commented 5 years ago

TclError: character U+1f63b is above the range (U+0000-U+FFFF) allowed by Tcl

The cause is that tk and python does not support the UCS4. Please rebuild tk, tcl and python 2.7 while referring https://github.com/cpbotha/nvpy/issues/150#issuecomment-315647089 and https://github.com/yuuki0xff/docker-nvpy/blob/master/Dockerfile.

This problem is confusing to the user. I will implement a feature to notify the user about this problem.
Regarding https://github.com/cpbotha/nvpy/issues/180#issuecomment-489398908, I will deal with it as a separate issue.

yuuki0xff commented 5 years ago

I closed it by mistake.

yuuki0xff commented 5 years ago

Added feature that notify users of UCS-4 issue. It will prevent user confusion.

5371ed34952a7152a5f45df4091c7ce51e087b02...992a40c59eff3e0c1a62d45a90d91a412b501ada