Jump to content
Sign in to follow this  
Czar

loading images

Recommended Posts

The behaviour for this

 

BackImg.LoadFromURL('res/back1366.png');

 

has changed since the last update. It works fine in browsers (internal and external) but it no longer works in my app that uses chromium (CEF4). 

At the moment if I compile in older version - all good - recompile in newer version and the images don't load if I use my delphi based chromium browser.

Any suggestions about where to start looking for a solution? I am using the browser app for all of my SMS based software so this represents a significant problem for me.

 

Share this post


Link to post
Share on other sites

I have since updated my CEF4 code with the latest version. No change.

I have made a very simply VCL sms program with an image loading a png. And it fails when opening via CEF4 browser. If I copy the index.html into a webserver then the browser will show images but not when it is a local file.

I have been using this browser for a number of years to display SMS index.html files so I would keen to have it resolved the change is the new SMS version.

Share this post


Link to post
Share on other sites

it is a cors error

Access to Image at 'file:///C:/Users/...../res/object.jpg' from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access.

would be very interested in getting a solution for this too

 

Share this post


Link to post
Share on other sites

Gonna have a look. Hang tight.

First thing you should test: See if you have app.manifest -file there causing problems. So try comparing or deleting the manifest file if it exists.

Share this post


Link to post
Share on other sites

1. deleting manifest has no effect.

2. Putting in cross origin no effect.

If I compile again with older SMS then it works correctly. Compile with current and it doesn't.

Share this post


Link to post
Share on other sites

@Czar Try removing line 311 from SmartCL.Controls.Image.pas:
 

SetCrossOrigin('Anonymous');

If it doesn't help, please zip the www-folders for me compiled with both the old and new version and send them to jt at smartmobilestudio.com

Share this post


Link to post
Share on other sites

www.numberworks.com/downloads/ImageProblem.rar

Open SimpleBrowser.exe and insert these into address (change to suit location :) )

c:\ImageProblem\wwwCURRENT\index.html
c:\ImageProblem\wwwWORKS\index.html

 

If you go to wwwCurrent you will see image location - but no image. If you try wwwWORKS then you will see a green screen. Only difference between these two is which version of SMS was used.

Share this post


Link to post
Share on other sites

Ok,

29 minutes ago, jarto said:

@Czar Try removing line 311 from SmartCL.Controls.Image.pas:
 


SetCrossOrigin('Anonymous');

If it doesn't help, please zip the www-folders for me compiled with both the old and new version and send them to jt at smartmobilestudio.com

Removing this line fixes the problem, but there's something weird going on with that Simple Browser app:

This works: file:///C:/ImageProblem/wwwCURRENT/index.html

This does not: c:\ImageProblem\wwwCURRENT\index.html

Hmm.... now it works again with both paths. Weird. But anyway, that SetCrossOrigin -call is the source of the problem. Going to make sure that it's called only when needed.

Share this post


Link to post
Share on other sites
2 minutes ago, Czar said:

You sir are a life saver. I have tested my initial projects and they now work again as expected.

Can I assume that "SetCrossOrigin('Anonymous');" won't make a return in later versions :)

I'll find out if there was a reason it was added. This change came when @lennartfixed images to work with streams. If that is needed for streams, I'll simply move it so it's set on demand. If it's not needed at all, I'll remove it.

Share this post


Link to post
Share on other sites

It is a standard property available for JS developers. There was no other reason for adding it than making it available also to Smart developers.

It was unfortunate that it was initialized with "anonymous", which sadly is the cause of this mess.

My apologies

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×