System.AccessViolationException

72 views
Skip to first unread message

ivbor

unread,
Sep 3, 2015, 1:35:01 PM9/3/15
to CefSharp
Hi. I started to use  cefsharp/41 for my application, but noticed that after some time of work application window hangs (UI thread bloks). When run it from Visual Studio I noticed AccessViolationException (place of exception is not stable, sometimes it occures in mscorlib.dll, sometimes in CefSharp.Core.dll - may be are other places). So I decided to check "pure" CefSharp.WinForms.Example, and also noticed this. 
Test environment: VS2013, Windows 7 SP1, En Locale, 64-bit. Inter Core I7-3632QM, 8 GB RAM

Steps to reproduce:
1) Get repo
cd /cygdrive/d/
mkdir cefsh_check
cd cefsh_check/
cd CefSharp/
git checkout cefsharp/41

Head now:
git rev-parse HEAD
6a4b141fca210bd24b970936bd60a929d70ffea3

2) Open cefsh_check/CefSharp/CefSharp3.sln

3) Make CefSharp.WinForms.Example as Startup project and run Debug for test build

4) Put timer on form, set Interval = 500 (0.5 second), Enabled = True and add Tick event:
        
        private void timer1_Tick(object sender, EventArgs e)
        {
            var rnd = new Random();
        
            if (browserTabControl.TabCount >= 10) {
                //dispose some control if count more then 10
                var tabPage = browserTabControl.Controls[rnd.Next(browserTabControl.Count];
                var control = (BrowserTabUserControl)tabPage.Controls[0];

                if (control != null)
                {
                    control.Dispose();
                }
                browserTabControl.Controls.Remove(tabPage);
            }

            List<string> sites = new List<string>(new string[] { 
                "Google.com",
                "Facebook.com",
                "Youtube.com",
                "Baidu.com",
                "Yahoo.com",
                "Amazon.com",
                "Wikipedia.org",
                "Qq.com",
                "Twitter.com",
                "Google.co.in",
                "Live.com",
                "Taobao.com",
                "Sina.com.cn",
                "Linkedin.com",
                "Yahoo.co.jp",
                "Weibo.com",
                "Ebay.com"
            });

            
            var domain = sites[rnd.Next(sites.Count)];

            AddTab(domain);
        }
    
    
5) Also comment out all InvokeOnUiThreadIfRequired calls in 
"public partial class BrowserTabUserControl : UserControl"
- thay all relate only for GUI and have no metter in this test.
But when it uncommented there are sometimes exceptions about inovacation failed.

6) Wait some time until AccessViolationException wil happen (according to my experiments it takes from 10 minutes up to 1 hour, but not shure, may be it depends on other factors).

Can someone confirm such issues? May be you can recommend some stable version of cefsharp/cef without such errors? We can catch most of exceptions but AccessViolationException is real problem.

Alex Maitland

unread,
Sep 3, 2015, 4:49:04 PM9/3/15
to CefSharp
For reference all the handlers including the events are exected on different `CEF` threads, so any UI interaction will require marshaling onto the `UI` thread. Step 5 sounds questionable in this context (I haven't looked at your sample).

Please fork and push your changes to GitHub.

ivbor

unread,
Sep 3, 2015, 6:43:58 PM9/3/15
to CefSharp
Thanks for response! Fork is here https://github.com/ivictbor/CefSharp, and here is a diff: https://github.com/cefsharp/CefSharp/compare/cefsharp/41...ivictbor:cefsharp/41 . About  Step 5: Sorry for my inaccurate description: I meant commenting InvokeOnUiThreadIfRequired at all with code inside of them, not code unwrapping.

четверг, 3 сентября 2015 г., 23:49:04 UTC+3 пользователь Alex Maitland написал:

Alex Maitland

unread,
Sep 4, 2015, 4:13:18 AM9/4/15
to CefSharp
How long does it take to reproduce the problem? Was it a 32bit or 64bit build that failed?

ivbor

unread,
Sep 4, 2015, 10:41:20 AM9/4/15
to CefSharp
Sometimes it comes at first 10-20 minutes, but in most cases it takes near 1 hour of work, I think it is random. Win32 Debug build.

пятница, 4 сентября 2015 г., 11:13:18 UTC+3 пользователь Alex Maitland написал:

ivbor

unread,
Sep 9, 2015, 11:07:29 AM9/9/15
to CefSharp
Tested also 37 and 39 branches - they also show same issue on my machine. But CefSharp-1.25.8 works perfectly (tested during 5 hours and there were no crash). Seems like CefSharp-1.25.8 is sutable for my project but only miserable thing is that videos don't work on basic demo of (for example youtube). May be I need to install some plugin? 

пятница, 4 сентября 2015 г., 17:41:20 UTC+3 пользователь ivbor написал:

Alex Maitland

unread,
Sep 9, 2015, 5:22:30 PM9/9/15
to CefSharp
Sorry, cannot help you with 1.25.8, I've never used CEF1, so not familiar with it.
Reply all
Reply to author
Forward
0 new messages