lvcabral / brs-engine

BrightScript Simulation Engine - Run Roku apps on Browsers and Node.js
https://lvcabral.com/brs/
MIT License
79 stars 14 forks source link

offscreencanvas & webworker polyfill for non-chromium browser support? #96

Closed chadacious closed 1 year ago

chadacious commented 3 years ago

I'm considering brs-emu to potentially re-implement our PWA app in brightscript with the idea that we could then have a single code-base for all platforms (namely: web, android, ios & roku). For android and ios, the idea is to use their respective webviews with a native shell to host it.

However, due to the use of webworkers, offscreencanvas, and sharedarraybuffer, brs-emu is not compatible with iOS browsers like safari, and consequently the WKWebView. In fact, I don't think the android webkit supports SharedArrayBuffers, although offscreen canvas is supported. So I'm exploring options to see if the emulator could still be made to work on currently unsupported browsers and webkits.

One thought is to use some polyfills, or another, probably preferred way, is to build a fallback into brs-emu itself to not use certain features if it isn't detected. Has anyone involved with brs-emu considered this, or have any thoughts about it?

I recognize that offscreencanvas is being used to reduce jank and have smoother animations. But for the purposes in a PWA app, my thought is the animations may not be so intense as to be a problem, or one could disable or create alternative animations on devices that don't support certain features.

In my search for a multi-platform, single codebase solution for building our app, I've found that Flutter and React Native don't support Roku, although I do wonder if one day Flutter might. Youi Engine One IMHO, is not a reasonable approach from a scalability perspective and they seem to be defunct and no longer responding to inquiries which sends some red flags. Besides, you would be tied into their SDK forever.

Having a pathway to maintain a single code base for all platforms would be HUGE for small teams like ours! Of course, no-one is claiming that the BrightScript 2D drawing api would be anyone's preference for building a UI. But given Roku's stubborn determination to remain a closed system, and not support a webkit, the brs-emu seems to be the only real-world alternative today that holds some promise.

I'll plan to start a fork and begin familiarizing myself with brs-emu's implementation and see what it might take to get fallback support in place. If anyone involved in this project has any insight, let's exchange ideas.

lvcabral commented 1 year ago

Currently both FireFox and Safari (Webkit) supports offscreen canvas