Closed erickzanardo closed 4 years ago
Is it possible to know the context from within the methods, whether it is in web or not? Then we could maybe just make those methods a no-op when they are called from a web context.
It sure is, on the foundation lib there is a variable called kIsWeb.
I just wonder if we should just do nothing on this methods like you said, or to make an assert with a meaningful message
I think we should do nothing in that case but write a warning log message, so that people can easily run their app on web with the same code.
I just use kIsWeb on my games, eg (from GW):
if (!kIsWeb) {
if (debugDefaultTargetPlatformOverride != TargetPlatform.fuchsia) {
await Flame.util.setLandscape();
}
await Flame.util.fullScreen();
}
I just use kIsWeb on my games, eg (from GW):
if (!kIsWeb) { if (debugDefaultTargetPlatformOverride != TargetPlatform.fuchsia) { await Flame.util.setLandscape(); } await Flame.util.fullScreen(); }
So do I, the point here is to make these methods of Flame do not crash the game without any message/warning, which is what happens today
We cannot preload audios too when running on web or it crashes, it overflows the path_provider channel.
Overflow on channel: plugins.flutter.io/path_provider. Messages on this channel are being discarded in FIFO fashion. The engine may not be running or you need to adjust the buffer size if of the channel.
To prevent this just use kIsWeb to check if it's running on web.
if(!kIsWeb){
await Flame.audio.loadAll(
[
...
]
);
}
Fixed on #427, will be shipped on 0.25.0
There are some methods, like
Flame.util.fullScreen
that catastrophically crashes the game.I think we should or do nothing when the method is called and is web, or throw a better message.