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

[BUG] Running export_ci or export from HISE CLI Doesn't Properly Embed Webview Resources in Compiled Binaries #424

Closed
jackkilgore opened this issue Sep 13, 2023 · 1 comment

Comments

@jackkilgore
Copy link

jackkilgore commented Sep 13, 2023

Hi! I'm working with Lunacy to automate HISE exports.

Environment

Problem
When web view is present in a HISE project, the HISE CLI commands export and export_ci do not embed the web resources in the binary files. In contrast, exporting through the HISE GUI properly embeds all web resources in the final binaries. EG, the temporary file externalFile (supposedly) containing all web resources has size of ~200KB when running from CLI vs. a size of ~900KB from HISE GUI. Note, that changing the architecture, or standalone vs. plugin type, or cleaning the binaries/pooled resources does nothing to remedy the problem.

Namely it seems to be an issues with BaseExporter::exportEmbeddedFiles() call to ValueTree webViewResources = chainToExport->getMainController()->exportWebViewResources();

exportWebViewResources() seems to be a JUCE command with the following code:

Juce::ValueTree GlobalScriptCompileBroadcaster::exportWebViewResources()
{
	ValueTree v("WebViewResources");

	for (const auto& wv : webviews)
	{
		auto data = std::get<1>(wv);

		auto projectRoot = dynamic_cast<MainController*>(this)->getCurrentFileHandler().getRootFolder();

		// We only embed file resources that are in the project directory (because then we'll assume
		// that they are not likely to be installed on the end user's computer).
		auto shouldEmbedResource = data->getRootDirectory().isAChildOf(projectRoot);

		if (shouldEmbedResource)
		{
			auto id = std::get<0>(wv).toString();
			auto c = data->exportAsValueTree();
			c.setProperty("ID", id, nullptr);
			v.addChild(c, -1, nullptr);
		}
	}

	return v;
}

Perhaps the shouldEmbedResource is throwing a false negative due to the HISE CLI not correctly setting the project root?

Conclusion
This is just a theory. Anyway, let me know if you need any more info from me, or if you can reproduce it, or if I can do anything to help with the issue! The ability to completely automate the build process without a GUI would be quite nice! :,)

Cheers,
Jack

@jackkilgore jackkilgore changed the title [BUG] Running export_ci or export from HISE CLI Doesn't Properly Embed Webview Resources in externalFiles [BUG] Running export_ci or export from HISE CLI Doesn't Properly Embed Webview Resources in Compiled Binaries Sep 13, 2023
christoph-hart added a commit that referenced this issue Sep 22, 2023
@christoph-hart
Copy link
Collaborator

Unfortunately it can't be solved implicitely because the webview actually needs to be opened at least once to fetch all resources so in a command line context where no UI is present this will not work.

What you need instead is to export the project once from the GUI: If there is a webview present, it will collect and cache the embedded resources into a file in the Images folder:

/exported_webviews/Windows/WebviewID.dat
/exported_webviews/macOS/WebviewID.dat

I haven't checked whether the resource file created on Windows will also work on mac, so I've added two locations based on the OS - you can check whether the exported webview file on Windows works on macOS too, if that's the case you can just copy it over, otherwise you need to export it once on each platform (it might be possible that the OS native browsers will request different URL formats etc).

From then on the command line utility will pickup the cached version and make sure that the resources are correct. If you try to export it without the file present, it should throw a export error.

If you want to fully automate this you can include these files in your version control system but just remember to run the export once from the GUI when you make changes to the webview data.

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

2 participants