Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frame load interrupted error message when using customized FileSystem instance #5

Open
sofussts opened this issue Nov 9, 2020 · 3 comments

Comments

@sofussts
Copy link

sofussts commented Nov 9, 2020

I am trying to implement my own FileSystem code, but I am not able to get the assets/index.html file to be displayed properly. The UltralightSharp.SafeDemo runs well when the default AppCore.EnablePlatformFileSystem is used. Next I try to use my own by setting the FileSystem:

    var assetsPath = Path.Combine(asmDir, "assets");
    //Safe.AppCore.EnablePlatformFileSystem(assetsPath);
    Ultralight.SetFileSystem(MyFileSystem.GetFileSystem(assetsPath));

When my own implementation of the FileSystem is set (basically, just my own implementation of the callback methods) , then nothing is shown in the UI for the URL "file:///index.html" and the view.SetFailLoadingCallback method reports:

    URL: file:///index.html, Description: Frame load interrupted, ErrorDomain: WebKitErrorDomain, ErrorCode: 102

See the attached file for details on how the MyFileSystem class is currently implemented.
MyFileSystem.zip

Breakpoints in my code show that the FileSystemReadFromFileCallback is called as it is supposed to. I am able to load the data as UTF8 byte array and return the data (the test code that is commented out below shows that the data is loaded from the file into the string s) :

    fs.ReadFromFile = new FileSystemReadFromFileCallback((handle, data) =>
    {
        uint nRead;
        byte[] bytes = new byte[data.Length];
        if (ReadFile(handle, bytes, (uint)data.Length, out nRead, IntPtr.Zero))
        {
            data = new ReadOnlySpan<byte>(bytes);
            //string s = Encoding.UTF8.GetString(data.ToArray());
            return (long)data.Length;
        }
        return -1;
    });

After this method is done the FileSystemGetFileMimeTypeCallback method is called, where I set the returned result to the hardcoded mime type: "text/html" and return true.

After that the next thing that is logged is the reported error message. Is there some sample code that demonstrates how to build a custom FileSystem instance in c#? What is the problem causing the reported error message?

I am currently using ultralight-sdk-1.2.0-win-x64-min with the latest version of UltralightSharp from the master branch.

@Tyler-IN
Copy link
Contributor

The UL# distribution includes a build of UL 1.2.0-beta - the API for stable may be different.

I'm unsure what the problem here is yet, but I'll address it for the UL# 1.2 stable release.

@sofussts
Copy link
Author

sofussts commented Nov 11, 2020

Tested with UL v1.2.0-beta.2. Same behaviour and error as with the stable version.

Please note that when I try to test with the binaries distributed with the UltralightSharp SDK in the folder UltralightSharp-master\UltralightSharp.Core.WinX64\runtimes\win-x64\native, it seems that these are built for the AMD processor (or something else) so I get an error message when I try to use them:

System.BadImageFormatException: ' is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)'

@SupinePandora43
Copy link
Contributor

Afaik it finally was fixed in 1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants