Page 1 of 1

Dragging file to browser sometime fails in OSR mode

Posted: Tue Apr 20, 2021 12:25 am
by tad.chen
In one of my website which needs account to log in, allow user to drag text file to an area, then the content of text file will be shown in the area. In normal mode, it works correctly. But in OSR mode, the content can't be shown. After that, I test it in some simple website which has the same function, both of the two modes can work correctly.

I don't know the reason. In OSR mode, browser will call chrmosr.InitializeDragAndDrop(Self) in the beginning, all the dragging is handled by CEF4Delphi. So, I don't know how to debug it.

Re: Dragging file to browser sometime fails in OSR mode

Posted: Tue Apr 20, 2021 8:40 am
by salvadordf
Hi,

Try the SimpleOSRBrowser demo on that website.

If it doesn't work with SimpleOSRBrowser then try the official CEF sample application. It's available here :
https://cef-builds.spotifycdn.com/cef_binary_90.5.4%2Bgc6a4331%2Bchromium-90.0.4430.72_windows32_client.tar.bz2

Use this command to run cefclient in OSR mode :

Code: Select all

cefclient --off-screen-rendering-enabled
Try disabling GPU acceleration in your application if you had it enabled.

Re: Dragging file to browser sometime fails in OSR mode

Posted: Tue Apr 20, 2021 1:20 pm
by tad.chen
SimpleOSRBrowser can work correctly. But the web page is in the popup window, not the default window. Because After I log in the website, it will popup a new tab or window where the area for dragging file is.

So I modify the code in chrmosrBeforePopup event to allow popup window (SimpleOSRBrowser' code blocks all popup windows and new tabs).

But I don't know whether Popup window is still is OSR mode. The dragging file icon is different in the popup window and the default window.

The CefClient can't work, because it blocks dragging file.

Re: Dragging file to browser sometime fails in OSR mode

Posted: Tue Apr 20, 2021 1:26 pm
by salvadordf
Open the PopupBrowser demo with Delphi and add the InitializeDragAndDrop and ShutdownDragAndDrop calls to the child form.

Then test your website with the modified PopupBrowser demo.

Re: Dragging file to browser sometime fails in OSR mode

Posted: Tue Apr 20, 2021 1:47 pm
by tad.chen
The PopupBrowser can work. And it can show the dragging file icon correctly (see attachment). But in SimpleOSRBrowser default window, the dragging file icon is very small.

Re: Dragging file to browser sometime fails in OSR mode

Posted: Wed Apr 21, 2021 2:04 pm
by tad.chen
I made a mistake. The web page for dragging is in the second popup window, the web page sequence is default window => popup window => popup window (we want).

I check the code of PopupBrowser and find that Chromium1BeforePopup event is not handled in childform (may be a bug), which means that it will not use the childform to popup a new window if user click some link in the childform. Thus, when I find dragging file is OK, it's not childform, but internal popup window.

I modify the code of childform, let it popup window in a new childform. Then test again and find that childform even can't support dragging file. The forbid icon is shown when file is dragged over. But InitializeDragAndDrop is called in its CreateClientHandler function. I don't know the reason. But the Mainform supports dragging. The difference between mainform and childform is that mainform uses CEFWindowParent and childform uses bufferpanel. I don't know whether it's the reason.

Re: Dragging file to browser sometime fails in OSR mode

Posted: Thu Apr 22, 2021 8:11 am
by salvadordf
Thanks for reporting this issue! :D

I just uploaded the fix for that demo and I also added a couple of buttons in the PopupBrowser.html file to test drag and drop.

The last button allows to drag a file and it works in the new child window.

Re: Dragging file to browser sometime fails in OSR mode

Posted: Thu Apr 22, 2021 1:58 pm
by tad.chen
It works now. Thank you :D