salvadordf/CEF4Delphi

Problem with samesite application inside iframe when using Minibrowser with Delphi7

PTz0uAH opened this issue · 8 comments

Using chromium-118.0.5993.119_windows32, the latest CEF4Delphi and Delphi7..

On a secure domain I load a samesite hosted application (vAmigaWeb) into an iframe and SimpleBrowser (for Delphi7) perfectly handles the iframe while the slightly adapted (for Delphi7) Minibrowser example (crashes vAmigaWeb) with an out of memory error..

`applied edits to make MiniBrowser run with Delphi7

[MiniBrowser.dpr]
//{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
const IMAGE_FILE_LARGE_ADDRESS_AWARE =$0020;

[uMiniBrowser.pas]

type
TBytes = array of Byte;

[implementation]

function BytesOf(const Val: AnsiString): TBytes;
var
Len: Integer;
begin
Len := Length(Val);
SetLength(Result, Len);
Move(Val[1], Result[0], Len);
end;

// GlobalCEFApp.UncaughtExceptionStackSize := 50;
// GlobalCEFApp.OnUncaughtException := nil;//GlobalCEFApp_OnUncaughtException; (gave an error wrong type)
//GlobalCEFApp.ChromeRuntime := True;
`

The same iframe tested with latest Firefox, Edge and Chrome 118.0.5993.117 (official build) works fine..

The same application loaded from an external secure domain though.. also loads fine into the iframe.. so it seems the self hosted one gives problems..

Is it perhaps possible to configure Chromium in the MiniBrowser in a way having the same capabilities as the Chromium used in SimpleBrowser or have I encountered a Chromium anomalie or permission issue?

the debugger of MiniBrowser show this..

taws_debug6

Hi,

MiniBrowser, SimpleBrowser and SimpleBrowser2 use a browser in normal mode.

SimpleBrowser uses a TChromiumWindow component. MiniBrowser and SimpleBrowser2 use TChromium and TCEFWindowParent but this should not be a problem.

I'm not an Amiga expert but I just tested MiniBrowser with https://vamigaweb.github.io/ and it seems to work fine. You can drop a kickstart rom, then drop a workbench image and it shows a desktop with a floppy and a red mouse.

You can also test this with the MiniBrowser demo made for Lazarus.

This suggests that the cause of this problem is in the MiniBrowser conversion to Delphi 7.

You can also test this with the MiniBrowser demo made for Lazarus

I will check as soon as I have Lazarus available.. because at first I thought it was maybe a 32bit thing.. because vAmigaWeb allocates 400mb memory at start and maybe needed Lazarus64 to get more memory headroom..

but I just tested MiniBrowser with https://vamigaweb.github.io/ and it seems to work fine

Yes I 'm aware of the fact that a direct call works even with the (probably incomplete converted) D7 MiniBrowser but I'm encountering the problem when I use an iframe..

When using SimpleBrowser it works as expected.. the windowed iframe vAmigaWeb1 runs correctly.. the externally called vAmigaWeb2 from github also runs fine..
SimpleBrowser

The following MiniBrowser (D7 converted) debug screenshot shows vAmigaWeb2 which points to https://vamigaweb.github.io/ which runs fine inside the windowed iframe but vAmigaWeb1 calls the self-hosted exact same version of vAmigaWeb from "./TS0CA/".. and crashes..

taws_debug2

taws_debug4

p.s. I removed some artefacts from the TAWS code and together with the vAmigaWeb developer we ruled out possible vAmigaWeb anomalies so I narrowed it down to MiniBrowser.. now I am going to install Lazarus to see if it makes a difference..

This suggests that the cause of this problem is in the MiniBrowser conversion to Delphi 7.

I now can confirm that the Lazarus compiled untouched version of MiniBrowser 32bit windows works as expected so the bug most likely comes from my conversion of MiniBrowser for use with Delphi7..

So I have to dig into that to get it to work properly.. any ideas about getting MiniBrowser to work correctly with Delphi7 are welcome..

Since it was not really a CEF4Delphi problem I guess we can close the issue until I get any "hard evidence" concerning the presumed bug.. Cheers!

The MiniBrowser demo has too many features that are not really useful outside a open source project demo.

The first thing I would do is disabling all the TChromium events that are only used in MiniBrowser and not in SimpleBrowser2.
Disable also the GlobalCEFApp.OnUncaughtException event and the code for the popup menu.

In that way you should have a browser with navigation buttons and an address box but vAmigaWeb should work.

Then you can enable only the features you need one by one.

I just uploaded the MiniBrowserD7 demo for Delphi 7. It's an extremely simplified MiniBrowser. I had some issues dropping files but I could load workbench.

@salvadordf thanks for the effort I really appreciate it!

I also found the D7 conversion fault leading to the error as described..

[MiniBrowser.dpr]
//{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}
const IMAGE_FILE_LARGE_ADDRESS_AWARE =$0020;

which should be in my simple MiniBrowser conversion

[MiniBrowser.dpr]
const IMAGE_FILE_LARGE_ADDRESS_AWARE =$0020;
{$SetPEFlags IMAGE_FILE_LARGE_ADDRESS_AWARE}

I never ever used the $SetPEFlags in D7 so I wrongly assumed it was a modern Delphi compiler-directive feature only.. and outcommented it.. I feel so stupid.. because the answer was also right under my eyes thanks to the dpr of simplebrowserD7 where $SetPEFlags was directly assigned..

now it seems to work.. even dropping files and starting multiple vAmigaWeb instances.. exciting..

now I am going to test if the chrome-mode also works.. for pointer integration and other API's like serial/midi to give vAmigaWeb those "devices".. btw it already works to some extend with the Lazarus MiniBrowser..

I'm glad it worked out because now I don't have to ditch D7 to get things done..

Thanks for the const suggestion!
Glad to help a fellow retrocomputing fan. :)

Hoi (ola) @salvadordf .. actually my Amiga-adoration never really "left the building".. so I try to avoid using "Retro".. I'm more like "OldSchool" hence also my Delphi7 "crush".. and other vintage habits,,

The main "beauty" in my current collection.. a Commodore Amiga 1200 still runs.. since 1993.. and now "she" is gonna get some "playmates" via vAmigaWeb.. via serial and midi.. we'll see what is possible..

I even bought an old A500 case to "prototype" an exclusive vAmigaWeb machine.. with a refurbished/partly repaired A500 keyboard + an Arduino to get it to work as USB keyboard + real slimline floppydrive to read/write floppies if needed for the real Amiga's.. and backing up any floppies that are still readable..

"MasterPlan" is.. in the end.. to run a selfcontained vAmigaWeb environment from a secure webserver + custom pre-configured multiplatform "Legacy Browser" for the infrastructures I work with (win32/win64/linux) build with CEF4Delphi.. and all the backed-up/found Amiga goodies.. amongst my BlitzBasic and other devstuff saved from back in the day upto the present day.. all running from USB-stick placed inside the unused spot of a fullsize drive eject-button..

Here some D7 MiniBrowser debugging and WIP.. though still in Alpha stadium.. it already feels great..

PB130370
PB130368