Can I integrate a native app in a web browser? - web

I need to display a native app (in my case, a video game built on unity) in a web browser page.
Local video and input streaming would be a solution, but video encoding is consuming too much computer resources.
Is there a way to display a native app in a web browser page?

Sure, you need to compile your application for WebAssembly. Or, to be more precise, cross-compile it, since WebAssembly binary code runs on a virtual stack machine.
You take your native code, compile it into a .wasm module, and then load that .wasm module with WebAssembly.instantiateStreaming().
There are many toolchains that can have WebAssembly as the compilation target. I think the 2 most popular ones are Emscripten and wasm-pack.
There is also wabt, but that is rather a set of lower level tools, not quite a toolchain.
And since you mentioned Unity, I have no experience with it, but there is some official documentation on WebAssembly.
Here is a game that was developed in C# and cross-compiled to WebAssembly.

Related

JXcore vs Electron

question
I am wondering what the main differences are between Electron and JXcore.
background
I was thinking about how I could make a NodeJS server into an app and I came across both of these. They seem to do the same thing, except that JXcore supports mobile and Electron doesn't.
side question
If Electron doesn't support mobile then how was the slack mobile app created?
Thanks in advance!
From the JXCore site(http://jxcore.com/tech/):
JXcore is a fork on the open source Node.js project
It uses LLVM to compile javascript as opposed to V8 which NodeJS does.
In terms of what are the main differences- Electron is a framework for building native, cross platform desktop applications, where it appears JXCore is a javascript engine forked from NodeJS.
Electron is built with NodeJS, and Chromium. So to make it fair, the comparison would be better stated "How does Electron work with NodeJS vs JXcore". Since I don't have any experience with JXCore, I can't answer that question. I would venture to say the only way to know that is to fork electron and replace Node with JXCore.
Based on your background, I would assume you are thinking about making one application that works cross platform across mobile and desktop environments. To that, I would say it is possible, but you are going to have 2 different projects. There are things in Electron that you wouldn't want included in your mobile app, since they are working with completely different operating systems. You are right that electron does not support mobile (it wasn't built for that).
As far as your side question goes, there are any number of technologies that slack could have used to create their mobile app. They could have used Java , Swift, Objective-C, .NET, Ruby, or Javascript.
There are cross platform tools such as RubyMotion, NativeScript, React Native, and Xamarin that could also be used to create native mobile apps, that all compile down into the native language the mobile OS understands.
A final approach could be the use of tools such as Cordova/Phonegap which create mobile apps via a "web view". Essentially, this is like creating an app that launches a web browser to interact with your phone.
If you are looking for an example on how to build once and use everywhere, I would look at the github repo found here https://github.com/NathanWalker/angular-seed-advanced. This shows a common codebase that can be used in Electron, Web, and Mobile.

Integrate C++ on webOS project

I'm developing a project for webOS 3.0 and I want to know if it's possible to integrate a C++ lib binary on a webOS aplication. I am tying to use nodejs addons and require the addon.node file into a JSservice like a module, but, according to this official LG developer it's not possible to integrate addons including C/C++ on webOS 3.0:
You cannot use modules including C/C++ addons. You must use modules implemented with JavaScript only.
I also tried using emscripten. This approach is not very convenient because it requires manually keeping track of all exported methods. As this project is maintained for several platforms and the code is already quite large, this becomes a hassle. The maintenance overhead would grow.
The question is whether there are any other ways of integrating C++ on webOS 3.0. Neither of the approaches I found seem ideal.
Sadly no.
WebOS on Palm supported C++ modules via their Plug-In Development Kit (PDK).
Unfortunately, to the best of my knowledge, it's not supported on LG TVs.

MEF support on Xamarin.iOS

I am wanting to port a C# Mobile App for Windows 8 tablets using Xamarin. One of the issues we foresee is the use of MEF. Does Xamarin.iOS support MEF?
It depends on what you mean by MEF support. Using MEF assemblies is possible using Xamarin.iOS. What's not possible (iOS restriction) is dynamically loading code in your application (e.g. plugins).
You might be able to use MEF while ensuring there's not dynamic code being loaded, i.e. that everything is statically referenced and built inside a single binary executable (e.g. by ensuring every plugin is built-in).
Depending on your application that could prove useful (no, or less, need to modify your existing application) or not (if your app can't load/be built with all plugins). In the later case your problem is with iOS itself (not Xamarin).

Will Firefox OS support C libs?

I'm developing a cross-mobile platform framework using C as base. Then i will make some wrappers for each specific platform (like ios, android, bb). One of my targets platform is firefox-os. I de like to know if will be possible to use c libs in firefox-os, but i couldn't find anything about it.
If you look at the following Firefox OS architecture document it should answer your questions:
https://wiki.mozilla.org/B2G/Architecture
For example, under Gaia it says, "Its only interface to the underlying operating system is through Open Web APIs, which are implemented by Gecko." That means that Javascript is the only interface you have to lower-level calls provided they are available via the Open Web APIs.
A workaround would be compiling your C code to JavaScript with emscripten. Firefox will implement asmjs in the near future, so the compiled code will probably be very performant (since emscripten will target asmjs as output).

embedded browser using XULRunner

Are there any examples of to use XULRunner to embed the browser control inside a app? (preferably in c or c++ for native win32 apps)
I have tried QT, wxWidgets, Awesomium, chrome embedded, LLmozLib, midori and Embedding/NewApi/Win32
The best one is wxWebConnect (which is part of wxWidgets framework). Why, cause you don't need the whole mozilla code base to build it plus the actual browser control is perfect as in plugins work, everything is rendered correctly (gmail, youtube etc etc)
So what's my problem or question? Well the wxWebConnect uses XULRunner to embed the browser control, my application is native win32 app and not wxWidgets app. I've searched the net to find another example of how use XULRunner to embed the gecko browser in native win32 apps..without luck!
Anyone know of projects/code that just use XULRunner and not require the entire mozilla source tree?
Thanks.
There's a list of XULRunner-based applications at
https://developer.mozilla.org/en/XULRunner_Hall_of_Fame
Whether you use wxWebConnect or embed XULRunner directly you are still going to have as part of your applications deployment the XULRunner engine and it's folder hierarchy. That's the nature of the beast.
Try GeckoFX, if you are okay with using .NET. Looking at the GeckoFX code might also give you enough insights to embed xulrunner in your native C++ Win32 app.

Resources