Iframe won't load content until devtools are opened - cefsharp

Problem:
I use CEFSharp to serve local content in a C# application.
In some cases I've got several iframes that should load different local URLs based on user actions.
I load content in those iframes using the Iframe.LoadUrl method. The URL is using the file schema.
In runtime, the application does not load the new url for the iframe until I open the devtools. When I do that, the iframe's contents are loaded perfectly and quickly.
This only happens once per iframe: After opening devtools, I can execute the same code and the iframe's contents are updated accordingly. I'm guessing the iframe's state is wrong somehow, but so far I haven't found any differences before/after opening devtools.
Context:
This application was running OK in CEFSharp 85.3. The library's version was upgraded to 101.0.
The code I'm working on is a plugin, and the initialization is managed by the main app, so I have little flexibility there. I could request changes if reasonable though.
Has anyone seen something like this before?

I've found a workaround for now, it seems to be working fine:
instead of doing:
frame.loadURL(url)
I'm using:
frame.Parent.ExecuteJavaScriptAsync("document.getElementById('" + frame.Name + "').src = '" + url + "'", "file:///");
I'm not really happy with my solution, but it seems to be working for now in my case.

Related

Download a file from a permalink URL, and not a direct exe url

So I am using InnoSetup 6 which natively supports downloading files from the internet during installation. I have figured out downloading files given a direct link, from this thread Inno Setup: Install file from Internet
However, I can't for the life of me figure out how to download the latest version of a file given a permalink URL. My specific example is to download the Microsoft Hosting package.
https://dotnet.microsoft.com/permalink/dotnetcore-current-windows-runtime-bundle-installer
Going to this page automatically downloads the latest package.
Inno doesn't like this link (or I don't know how to get Inno to use it) since it doesn't point to the direct file. If I use the direct link (https://download.visualstudio.microsoft.com/download/pr/24847c36-9f3a-40c1-8e3f-4389d954086d/0e8ae4f4a8e604a6575702819334d703/dotnet-hosting-5.0.6-win.exe) this works for obvious reasons.
I'd like to always download the latest, but I'm not sure how to accomplish this. Any suggestions?
Adding super basic code being used...
DownloadPage.Clear;
DownloadPage.Add('https://dotnet.microsoft.com/permalink/dotnetcore-current-windows-runtime-bundle-installer', 'dotnet-hosting.exe', '');
DownloadPage.Show;
You would have to retrieve the HTML page, find the URL in the HTML code and use it in your download code.
See Inno Setup - HTTP request - Get www/web content
It would be quite unreliable. Microsoft can change the HTML any time.
You better setup your own webpage (web service) that will provide an up to date link to your installer. The web page can even do what I suggested: retrieve the URL from the Microsoft's download page. In case Microsoft changes the HTML, you can fix your web page any time. What you cannot do with the installer.
Without realizing it you are asking two different question here. That is because these "permalinks" aren't really permalinks but redirects to some dynamic resource that has a link to what you are looking for.
So first, addressing the Microsoft "permalink", you need to realize that under the hood you are accessing a URL that redirects to some page which will point to the latest. Then under the hood, that page invokes a JavaScript function, IF YOU ACCESSING VIA A WEB BROWSER, to download the installer. Note that both the page pointed to and the code to invoke the installer WILL eventually change. In fact, the code itself logs a "warning" when people attempt to download directly:
If you do a view source you'll see:
<script>
$(function () {
recordDownload('.NET', 'runtime-aspnetcore-5.0.6-windows-hosting-bundle-installer');
window.open("https://download.visualstudio.microsoft.com/download/pr/24847c36-9f3a-40c1-8e3f-4389d954086d/0e8ae4f4a8e604a6575702819334d703/dotnet-hosting-5.0.6-win.exe", "_self");
});
function recordManualDownload() {
ga("send", "event", "Download.Warning", "Direct Link Used", "runtime-aspnetcore-5.0.6-windows-hosting-bundle-installer");
}
</script>
So you can download the HTML from this page and use some regex to get the directo downloadlink but beware, the link is going to change every time Microsoft releases a new version. Furthermore, WHEN (not if but when) MS decides to rebrand this entire process might break. So the best you can do here is try to download the html and try parse the download URL from this "permalink"
As an alternative. you can to download the latest DotNet powershell install script as described here.
If possible, execute that script directly. If not look at the function Get-AkaMSDownloadLink within the install script to see how it builds the url to get the latest version. You would probably be better served using that building and using that URL as opposed to attempting to download from some arbitrary HTML code.
Now, onto the second question you might not have realized your were asking is how to automate this for any random installer. The answer is you can't. Some might have a permalink that directly points to the latest but you are always going to find cases like Microsoft. Best you can down is hard code some links in some service, as #martin-prikryl suggested, and when the break update the links in those services.

DirectShow webcam preview inside Firebreath plugin, not showing the preview after I refresh the webpage

I created a sample application to show the webcam preview using DirectShow inside the firebreath plugin window. It is working fine when I load the webpage first time, but is it not working after I navigate to another pages and return back to the plugin page. It is also not working after I refresh the webpage. Any idea?
Sounds like something isn't getting cleaned up properly or possibly you're using some global resources that are getting shared between plugin instances that doesn't get completely reset.
Remember that a plugin isn't unloaded between instances, so if you use any global/static variables the process is not shut down between instances of the plugin; this causes trouble for a lot of libraries used in a plugin that were written for an application, as most applications that use directshow figure the process will be closed before anything is used again and thus don't clean up after themselves completely.
Anyway, with what info you've given us that's my best guess. It might not be something obvious -- it could be something inside directshow.

How can I properly refresh a Durandal SPA web app when new views are added?

I'm just starting to play with Durandal, using the starter kit. I've added a very simple new view/viewmodel combination (essentially a copy/paste of an existing one from the sample) and mapNav()'d the route.
The problem is happening when I try to refresh my browser...the new view simply does not appear. It's not in the nav bar, nor can I navigate directly to the view by typing in the address bar. I know the code is (or should be?!) correct because if I go to the page in a different browser, everything appears as it should.
Is there some browser caching that Durandal is doing somehow? Sometimes F5 or Ctrl+F5 works to refresh, sometimes it doesn't. I also can't deep-link to a specific 'page'. Ie:
http://localhost:52625/#/newpage just gives me a blank
What am I missing?
The option that I use in Chrome is to open developer tools and right-click on the refresh button. There is an option for 'Empty Cache and Hard Reload' which always fixes this issue for me. I don't know the equivalent in IE but try this and see if it fixes your issue.
Most browsers will cache modules returned via RequireJS, which is how Durandal obtains its modules and view models.
CTRL+F5 doesn't help because that just refreshes the initial page - all the modules are still requested using javascript (RequireJS), so they are usually pulled from cache first.
I've found it's best to disable caching in your browser's developer tools. Doing so will ensure that all network requests are loaded directly from the source and not from cache.
See this question for additional information: Debugging when using require.js cache
Another solution is configure RequireJS to set its urlArgs property: https://stackoverflow.com/a/8479953/91189
This solution works ok, but makes it harder to debug, at least in Chrome, because breakpoints are lost every time the module is loaded, since it's technically a different file being requested each time.

What can be preventing this cdn file from loading on my webpage?

I wish I had a more generic way of asking this question but I really can't figure out what could be going on.
Using dev-channel Chrome 26 (and IE 10) I'm hitting a simple html site in my public dropbox here
In my browser Handlebars.js (from cdnjs.com) never loads and I get an error. Heck, according to the Network tab it never even tries to load it. Yet click through the source and the script file - it is definitely a live link. Why handlebars? Additionally, running the same exact site with a local server loads just fine.
I'm at a loss here what could possibly have this effect. You'd think the issue would be running the server in dropbox but it seems to be the actual browser misbehaving. And why on earth does it not make any request at all?
My repo by the way is on github on the preformance-tuning branch
It looks like Chrome is throwing an insecure content warning on your scripts. Most likely because you are trying to access content hosted over HTTP while your site is being served from dropbox using ssl. Most likely a Chrome security setting silently block scripts it considers "insecure"

Site.Master Changes

I started out with a basic site.master. After I laid out several pages, I have found that I need to make changes to the site.master. The changes show up while I am working in Visual Studio, but when I run the application, they don't take effect. What do I need to do to have them show up?
When you make changes to CSS or javascript (or any other static content, for that matter), you need to clear out the browser cache to ensure the latest version is loaded from your server.
You can force a reload from the server by using Ctrl + F5 on most browsers.

Resources