hbons / SparkleShare

Share and collaborate by syncing with any Git repository instantly. Linux, macOS, and Windows.
https://sparkleshare.org
Other
4.88k stars 576 forks source link

Unable to construct instance of type SparkleShare.EventLog+SparkleWebView #1798

Open glunardi opened 6 years ago

glunardi commented 6 years ago

What happened:

Gtk# exception crashes SS (master) on F27.

Here are the last entries in the log before the crash:

11:53:52 Git | delivery-process | Checking for remote changes...
11:53:52 Cmd | delivery-process | git rev-parse HEAD
11:53:52 Cmd | delivery-process | git ls-remote --heads --exit-code origin master
11:53:53 Git | delivery-process | No remote changes, local+remote: 50f6fa51b5e84564e1ddece8e6dd176d11f3cb4b
11:53:53 Git | managers | Checking for remote changes...
11:53:53 Cmd | managers | git rev-parse HEAD
11:53:53 Cmd | managers | git ls-remote --heads --exit-code origin master
11:53:54 Git | projects | Checking for remote changes...
11:53:54 Cmd | projects | git rev-parse HEAD
11:53:54 Cmd | projects | git ls-remote --heads --exit-code origin master
11:53:54 Git | managers | No remote changes, local+remote: 02d56dd7abf4610dda315bb6831c44a094ce3950
11:53:55 Cmd | projects | git merge-base b7bee202633fe132f02f5f0012b6ae2f09a733dc master
11:53:55 Git | projects | Remote changes found, local: 00a7064b1f795ee72fd7decaae6e13b859ea3bcf, remote: b7bee202633fe132f02f5f0012b6ae2f09a733dc
11:53:55 SyncDown | projects | Initiated
11:53:55 Cmd | projects | git rev-parse HEAD
11:53:55 Cmd | projects | git fetch --progress origin master
11:53:57 Git | remote: Counting objects: 18, done.        
11:53:57 Git | remote: Total 18 (delta 17), reused 0 (delta 0)        
11:53:57 Git | From ssh://xxxxx.xxxxxxxx.xxx/git/documents/projects
11:53:57 Git |  * branch              master     -> FETCH_HEAD
11:53:57 Git |    00a7064b..b7bee202  master     -> origin/master
11:53:57 Cmd | projects | git status --porcelain
11:53:58 Cmd | projects | git config core.ignorecase true
11:53:58 Cmd | projects | git merge FETCH_HEAD
11:53:58 Cmd | projects | git config core.ignorecase false
11:54:03 Cmd | projects | git --no-pager log --since=1.month --raw --find-renames --date=iso --format=medium --no-color --no-merges
11:54:05 Cmd | projects | git rev-parse HEAD
11:54:05 SyncDown | projects | Done

The trace:

Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
GLib.MissingIntPtrCtorException: Unable to construct instance of type SparkleShare.EventLog+SparkleWebView from native object handle. Instance of managed subclass may have been prematurely disposed.
  at GLib.ObjectManager.CreateObject (System.IntPtr raw) [0x00064] in <3eb93253711f4c08b41956dc83a81a30>:0 
  at GLib.Object.GetObject (System.IntPtr o, System.Boolean owned_ref) [0x00089] in <3eb93253711f4c08b41956dc83a81a30>:0 
  at WebKit2.WebView.DecidePolicy_cb (System.IntPtr inst, System.IntPtr decision, System.Int32 decision_type) [0x00000] in <6c1e1be6960844fe8a7266ffdb9ef388>:0 
  at GLib.ExceptionManager.RaiseUnhandledException (System.Exception e, System.Boolean is_terminal) [0x00000] in <3eb93253711f4c08b41956dc83a81a30>:0 
  at WebKit2.WebView.DecidePolicy_cb (System.IntPtr inst, System.IntPtr decision, System.Int32 decision_type) [0x00000] in <6c1e1be6960844fe8a7266ffdb9ef388>:0 
  at GLib.Application.g_application_run (System.IntPtr , System.Int32 , System.IntPtr ) [0x00000] in <440c5998093e4fc6a6ba2819c12be9f9>:0 
  at GLib.Application.Run (System.Int32 argc, System.String argv) [0x00000] in <440c5998093e4fc6a6ba2819c12be9f9>:0 
  at SparkleShare.UserInterface.Run (System.String[] args) [0x00000] in <04fab172dbfc471193322bca3923cb3a>:0 
  at SparkleShare.SparkleShare.Main (System.String[] args) [0x00000] in <04fab172dbfc471193322bca3923cb3a>:0 

What I expected to happen:

Apparently SparkleShare.EventLog+SparkleWebView failed which might imply a change underneath in webkit2gtk?

You can reproduce the issue like this:

Have not managed to reproduce manually. It appears to take quite a few hours of uptime before the crash would manifest itself.

glunardi commented 6 years ago

Happened again after 30 minutes (real uptime)

real    30m19.093s
user    0m21.296s
sys 0m16.781s

So it does not take that long. The stack is virtually identical:

Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
GLib.MissingIntPtrCtorException: Unable to construct instance of type SparkleShare.EventLog+SparkleWebView from native object handle. Instance of managed subclass may have been prematurely disposed.
  at GLib.ObjectManager.CreateObject (System.IntPtr raw) [0x00064] in <3eb93253711f4c08b41956dc83a81a30>:0 
  at GLib.Object.GetObject (System.IntPtr o, System.Boolean owned_ref) [0x00089] in <3eb93253711f4c08b41956dc83a81a30>:0 
  at WebKit2.WebView.DecidePolicy_cb (System.IntPtr inst, System.IntPtr decision, System.Int32 decision_type) [0x00000] in <6c1e1be6960844fe8a7266ffdb9ef388>:0 
  at GLib.ExceptionManager.RaiseUnhandledException (System.Exception e, System.Boolean is_terminal) [0x00000] in <3eb93253711f4c08b41956dc83a81a30>:0 
  at WebKit2.WebView.DecidePolicy_cb (System.IntPtr inst, System.IntPtr decision, System.Int32 decision_type) [0x00000] in <6c1e1be6960844fe8a7266ffdb9ef388>:0 
  at GLib.Application.g_application_run (System.IntPtr , System.Int32 , System.IntPtr ) [0x00000] in <440c5998093e4fc6a6ba2819c12be9f9>:0 
  at GLib.Application.Run (System.Int32 argc, System.String argv) [0x00000] in <440c5998093e4fc6a6ba2819c12be9f9>:0 
  at SparkleShare.UserInterface.Run (System.String[] args) [0x00000] in <04fab172dbfc471193322bca3923cb3a>:0 
  at SparkleShare.SparkleShare.Main (System.String[] args) [0x00000] in <04fab172dbfc471193322bca3923cb3a>:0

Trying to instrument CreateWebView () and SparkleWebView : WebView {} to see if anything obvious happens.

glunardi commented 6 years ago

It is quite possible this is related to this build time warning:

./EventLog.cs(237,69): warning CS0612: `WebKit2.NavigationPolicyDecision.Request' is obsolete

hbons commented 6 years ago

This is native, not inside the flatpak right?

glunardi commented 6 years ago

In my testing it is native install on F27.

Others have reported what seems like a similar crash using the flatpak but I have received to confirm or deny that. There is nothing in their logs.

hbons commented 6 years ago

It could well be the WebKit2.NavigationPolicyDecision.Request call. I couldn't find a a way to replace the deprecated call warnings with something in the current API.

Which WebKit2 bindings are you using? The ones from hbons/webkit2-sharp?

glunardi commented 6 years ago

rpm -qi webkit2-sharp-0-0.3.20170219gita59fd76.fc27.x86_64 Name : webkit2-sharp Version : 0 Release : 0.3.20170219gita59fd76.fc27 Architecture: x86_64 Install Date: Thu 28 Dec 2017 05:57:59 PM EST Group : Unspecified Size : 417536 License : MIT Signature : RSA/SHA256, Wed 27 Sep 2017 02:59:19 AM EDT, Key ID f55e7430f5282ee4 Source RPM : webkit2-sharp-0-0.3.20170219gita59fd76.fc27.src.rpm Build Date : Wed 27 Sep 2017 02:36:50 AM EDT Build Host : buildvm-25.phx2.fedoraproject.org Relocations : (not relocatable) Packager : Fedora Project Vendor : Fedora Project URL : https://github.com/hbons/webkit2-sharp Summary : C# bindings for WebKit 2 with GTK+ 3 Description : C# bindings for WebKit 2 with GTK+ 3

hbons commented 6 years ago

Are you able to open the Recent Events window at all?

glunardi commented 6 years ago

Indeed, I had checked and it does work. The crash does not happen when I actually try to open the "History..." dialog but rather all by itself and seemingly randomly.

screenshot from 2018-01-22 07-23-51

Sorry all my colleagues are boring and no one has an avatar :-).

glunardi commented 6 years ago

It could well be the WebKit2.NavigationPolicyDecision.Request call. I couldn't find a a way to replace the deprecated call warnings with something in the current API.

Could this possibly be any harder to track down?

I quickly looked and was not even able to figure out where or when the call was deprecated. Even worse, I can not figure out what it should be changed to.

Could we try without using the decision rule at all? If you have a link to what interface documentation to what you used for WebKit2 integration, I could try a few things.

hbons commented 6 years ago

It could be that the logic around https://github.com/hbons/SparkleShare/blob/release/2.0.0/SparkleShare/Linux/EventLog.cs#L226 is no longer needed because some behaviour in WebKit changed. You could try commenting some stuff out and see if the all the links still work?

glunardi commented 6 years ago

I have commented out the whole override method for now. It builds and runs. Will report back if it still crashes (or not).

Will try to look at why most of the links were already not working properly before (might be related). I had not noticed that before. Will open another issue if I can figure it out.

glunardi commented 6 years ago

Will report back if it still crashes (or not).

Just an update that it is still going. Will update tomorrow.

glunardi commented 6 years ago

Will report back if it still crashes (or not).

Just an update that it is still going. Will update tomorrow.

That looks like it might do the trick (still running). If still good tomorrow, I will submit a pull request.

glunardi commented 6 years ago

Adding here that this crash still occurs with the latest version (master)

Exception in Gtk# callback delegate Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception. GLib.MissingIntPtrCtorException: Unable to construct instance of type SparkleShare.EventLog+SparkleWebView from native object handle. Instance of managed subclass may have been prematurely disposed. at GLib.ObjectManager.CreateObject (System.IntPtr raw) [0x00064] in <3eb93253711f4c08b41956dc83a81a30>:0 at GLib.Object.GetObject (System.IntPtr o, System.Boolean owned_ref) [0x00089] in <3eb93253711f4c08b41956dc83a81a30>:0 at WebKit2.WebView.DecidePolicy_cb (System.IntPtr inst, System.IntPtr decision, System.Int32 decision_type) [0x00000] in <6c1e1be6960844fe8a7266ffdb9ef388>:0 at GLib.ExceptionManager.RaiseUnhandledException (System.Exception e, System.Boolean is_terminal) [0x00000] in <3eb93253711f4c08b41956dc83a81a30>:0 at WebKit2.WebView.DecidePolicy_cb (System.IntPtr inst, System.IntPtr decision, System.Int32 decision_type) [0x00000] in <6c1e1be6960844fe8a7266ffdb9ef388>:0 at GLib.Application.g_application_run (System.IntPtr , System.Int32 , System.IntPtr ) [0x00000] in <440c5998093e4fc6a6ba2819c12be9f9>:0 at GLib.Application.Run (System.Int32 argc, System.String argv) [0x00000] in <440c5998093e4fc6a6ba2819c12be9f9>:0 at System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod , System.Object , System.Object[] , System.Exception& ) [0x00000] in <373b6e083d6e45e498c9082a8eebd27f>:0 at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <373b6e083d6e45e498c9082a8eebd27f>:0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <373b6e083d6e45e498c9082a8eebd27f>:0 at SparkleShare.UserInterface.Run (System.String[] args) [0x00000] in <df31390bf39347f4b067f58a2e0f4610>:0 at SparkleShare.SparkleShare.Main (System.String[] args) [0x00000] in <df31390bf39347f4b067f58a2e0f4610>:0

I was not trying to open any of the dialogs. It was an unattended crash (which seems odd). Will try to keep an eye on it. Everything else appears to be working great now.

hbons commented 6 years ago

I think this happens when the web content is updated after a pull? The only thing that I can see that disposes the webview is:

            this.web_view.Dispose ();
            this.web_view = CreateWebView ();

What if you remove these two lines in EventLog.UpdateContent()?

glunardi commented 6 years ago

What if you remove these two lines in EventLog.UpdateContent()?

I have decorated those lines with log entries for now to see if something comes of it. will report back. Quite stable otherwise.

glunardi commented 6 years ago

Interestingly it would seem that the crash after "CreateWebView". Happened a couple of times that way now.

10:34:25 EventLog | Invoking Dispose webview in UpdateContent method 10:34:25 EventLog | Invoking CreateWebView in UpdateContent method Exception in Gtk# callback delegate Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception. GLib.MissingIntPtrCtorException: Unable to construct instance of type SparkleShare.EventLog+SparkleWebView from native object handle. Instance of managed subclass may have been prematurely disposed. at GLib.ObjectManager.CreateObject (System.IntPtr raw) [0x00064] in <3eb93253711f4c08b41956dc83a81a30>:0 at GLib.Object.GetObject (System.IntPtr o, System.Boolean owned_ref) [0x00089] in <3eb93253711f4c08b41956dc83a81a30>:0 at WebKit2.WebView.DecidePolicy_cb (System.IntPtr inst, System.IntPtr decision, System.Int32 decision_type) [0x00000] in <6c1e1be6960844fe8a7266ffdb9ef388>:0 at GLib.ExceptionManager.RaiseUnhandledException (System.Exception e, System.Boolean is_terminal) [0x00000] in <3eb93253711f4c08b41956dc83a81a30>:0 at WebKit2.WebView.DecidePolicy_cb (System.IntPtr inst, System.IntPtr decision, System.Int32 decision_type) [0x00000] in <6c1e1be6960844fe8a7266ffdb9ef388>:0 at GLib.Application.g_application_run (System.IntPtr , System.Int32 , System.IntPtr ) [0x00000] in <440c5998093e4fc6a6ba2819c12be9f9>:0 at GLib.Application.Run (System.Int32 argc, System.String argv) [0x00000] in <440c5998093e4fc6a6ba2819c12be9f9>:0 at System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod , System.Object , System.Object[] , System.Exception& ) [0x00000] in <373b6e083d6e45e498c9082a8eebd27f>:0 at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <373b6e083d6e45e498c9082a8eebd27f>:0 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <373b6e083d6e45e498c9082a8eebd27f>:0 at SparkleShare.UserInterface.Run (System.String[] args) [0x00000] in <6fd2d8cb6e0e4f22b3f075fbe8dece50>:0 at SparkleShare.SparkleShare.Main (System.String[] args) [0x00000] in <6fd2d8cb6e0e4f22b3f075fbe8dece50>:0

Will run it a little more this way and try to remove the disposal. You probably had a reason for it.

glunardi commented 6 years ago

Just confirming that the occasional crash is still happening with these lines in:

            this.web_view.Dispose ();
            this.web_view = CreateWebView ();

Will test again taking them out. I ran without them for a few days and noticed no side-effect.

glunardi commented 6 years ago

Caught another instance of this exception today with the latest master:

Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
GLib.MissingIntPtrCtorException: Unable to construct instance of type SparkleShare.EventLog+SparkleWebView from native object handle. Instance of managed subclass may have been prematurely disposed.
  at GLib.ObjectManager.CreateObject (System.IntPtr raw) [0x00064] in <3eb93253711f4c08b41956dc83a81a30>:0 
  at GLib.Object.GetObject (System.IntPtr o, System.Boolean owned_ref) [0x00089] in <3eb93253711f4c08b41956dc83a81a30>:0 
  at WebKit2.WebView.DecidePolicy_cb (System.IntPtr inst, System.IntPtr decision, System.Int32 decision_type) [0x00000] in <6c1e1be6960844fe8a7266ffdb9ef388>:0 
  at GLib.ExceptionManager.RaiseUnhandledException (System.Exception e, System.Boolean is_terminal) [0x00000] in <3eb93253711f4c08b41956dc83a81a30>:0 
  at WebKit2.WebView.DecidePolicy_cb (System.IntPtr inst, System.IntPtr decision, System.Int32 decision_type) [0x00000] in <6c1e1be6960844fe8a7266ffdb9ef388>:0 
  at GLib.Application.g_application_run (System.IntPtr , System.Int32 , System.IntPtr ) [0x00000] in <440c5998093e4fc6a6ba2819c12be9f9>:0 
  at GLib.Application.Run (System.Int32 argc, System.String argv) [0x00000] in <440c5998093e4fc6a6ba2819c12be9f9>:0 
  at System.Reflection.MonoMethod.InternalInvoke (System.Reflection.MonoMethod , System.Object , System.Object[] , System.Exception& ) [0x00000] in <373b6e083d6e45e498c9082a8eebd27f>:0 
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <373b6e083d6e45e498c9082a8eebd27f>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <373b6e083d6e45e498c9082a8eebd27f>:0 
  at SparkleShare.UserInterface.Run (System.String[] args) [0x00000] in <ce41a37f2b5149a386aefc0939c3e31d>:0 
  at SparkleShare.SparkleShare.Main (System.String[] args) [0x00000] in <ce41a37f2b5149a386aefc0939c3e31d>:0 

These lines are not currently patched out. I could make that change if you think it would be a useful test:

this.web_view.Dispose ();
this.web_view = CreateWebView ();
hbons commented 6 years ago

so did you get any crashes with the lines commented out before?

glunardi commented 6 years ago

so did you get any crashes with the lines commented out before?

I think so. I commented a few days back that:

Just confirming that the occasional crash is still happening with these lines in:

glunardi commented 6 years ago

Just a quick update that despite the issue still being there I believe, good uptime (probably 72hrs+)