Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Sometimes resizing the browser by 1 pixel causes crash in cef lib

tad.chen
Posts: 104
Joined: Fri Jan 04, 2019 1:39 am

Sometimes resizing the browser by 1 pixel causes crash in cef lib

Post by tad.chen »

I follow the suggestion from you by calling TChromium.WasHidden(True) to all the browsers that are not visible and then call TChromium.WasHidden(False) when they become visible. This will stop the TChromium.OnPaint event for that browser while it's hidden. There's a known CEF issue with this trick and you will have to resize the browser by 1 pixel after the TChromium.WasHidden(False) call to receive TChromium.OnPaint events again.

But I find that resizing by 1 pixel will cause crash in cef lib sometimes. Especially when resize frequently or browser is busy, it'll happen easily. How to fix it?
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Sometimes resizing the browser by 1 pixel causes crash in cef lib

Post by salvadordf »

Hi,

I've never seen that error and it's difficult to guess without a code sample.

All I can give are some generic suggestions :
  • Sometimes these weird issues can be fixed by moving some code outside the CEF events, specially if that code triggers some other CEF events. Try using TThread.ForceQueue around the code that might trigger CEF events.
  • Avoid using Application.ProcessMessages like the plague.
tad.chen
Posts: 104
Joined: Fri Jan 04, 2019 1:39 am

Re: Sometimes resizing the browser by 1 pixel causes crash in cef lib

Post by tad.chen »

Thank you for your suggestion.

But I read comments of the issue in https://bitbucket.org/chromiumembedded/cef/issues/2483/osr-invalidate-does-not-generate-frame.

And find a comment:
Resizing the browser by 1px smaller, then resizing it back to it's original size is the workaround we've implemented in CefSharp. Ignoring the frames until the resize has complete.

This proved to be much more difficult than I had originally hoped, the problem being resizing the browser in rapid succession in combination with a WasHidden call, it's fairly easy to trigger a breakpoint/assertion in Chromium. Think users switching between tabs in rapid succession.

I believe Chromium is going to remove the breakpoint/assertion...
So, I think my resizing by 1 pixel maybe triggers a breakpoint/assertion in Chromium as the comment.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Sometimes resizing the browser by 1 pixel causes crash in cef lib

Post by salvadordf »

I checked again this issue and the CEF project fixed it in CEF 94.

I just modified the FMXTabbedOSRBrowser demo to show and hide OSR browser tabs dynamically and it works correctly.

Please, upgrade to the latest CEF4Delphi version and try the FMXTabbedOSRBrowser demo.
tad.chen
Posts: 104
Joined: Fri Jan 04, 2019 1:39 am

Re: Sometimes resizing the browser by 1 pixel causes crash in cef lib

Post by tad.chen »

OK, I'll try it. Thank you!
tad.chen
Posts: 104
Joined: Fri Jan 04, 2019 1:39 am

Re: Sometimes resizing the browser by 1 pixel causes crash in cef lib

Post by tad.chen »

I tested the FMXTabbedOSRBrowser demo by showing and hiding OSR browser tabs dynamically and it works correctly.

But I find a new issue. I find VCL OSR browser can't work correctly as FMX OSR browser. If many VCL OSR browsers are opened, the calling to wasHidden(false) will fail. But If few VCL OSR browsers are opened, the calling is OK. FMX OSR browser hasn't this bug.

In order to test, I modify TabbedBrowser Demo, and let it run in OSR mode. The modified TabbedBrowser Demo source code is attached.

I use Back Button to hide browser and Forward Button to show browser. You'll find that show browser function fails if many tabs are opened.

I use CEF 95 library to test.
You do not have the required permissions to view the files attached to this post.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Sometimes resizing the browser by 1 pixel causes crash in cef lib

Post by salvadordf »

The TabbedBrowser demo uses a complicated way to handle tabs.
I should remake it using frames, like the FMXTabbedOSRBrowser and TabbedBrowser2 demos.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Sometimes resizing the browser by 1 pixel causes crash in cef lib

Post by salvadordf »

I just added a new demo called TabbedOSRBrowser that uses frames with browsers in OSR mode.

Please, download CEF4Delphi again and use this demo instead of TabbedBrowser.
tad.chen
Posts: 104
Joined: Fri Jan 04, 2019 1:39 am

Re: Sometimes resizing the browser by 1 pixel causes crash in cef lib

Post by tad.chen »

I just downloaded TabbedOSRBrowser Demo and tested. It works correctly.

But the modified TabbedBrowser still can't work if many tabs are opened.

I don't know the reason why TabbedBrowser doesn't work. It seams that they nearly the same, both based on OSR mode.
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Sometimes resizing the browser by 1 pixel causes crash in cef lib

Post by salvadordf »

The TabbedBrowser demo uses Windows messages to handle the tabs which works fine for a limited number of tabs but I guess it has synchronization issues when you create too many tabs at the same time.

Use the new TabbedOSRBrowser demo.
Post Reply