youtube_player_flutter icon indicating copy to clipboard operation
youtube_player_flutter copied to clipboard

[BUG] Grey Screen issue when you deploy web app

Open superman-danny opened this issue 1 year ago • 13 comments

It shows and works perfectly in development server but when it goes live or in release mode. I get a grey screen

LIVE Screenshot 2024-01-23 at 9 20 07 AM

PRODUCTION Screenshot 2024-01-23 at 9 20 07 AM (2)

superman-danny avatar Jan 23 '24 09:01 superman-danny

https://sarbagyastha.github.io/youtube_player_flutter/#/

Seems to be working, can you provide console logs ?

sarbagya-acme avatar Jan 28 '24 16:01 sarbagya-acme

I'm getting the same issue. Any solution?

moradiyajay avatar Jan 29 '24 06:01 moradiyajay

@superman-danny did you find any solution ? I am also facing the same.

droidbg avatar Mar 12 '24 08:03 droidbg

Same here, grey screen is the flutter production way to replace the big red error screen on debug btw. It's working perfectly on debug mode (using flutter run). But soon as I use the compiled web version, It turns into error. I managed to catch this : Null check operator used on a null value bjs@http://127.0.0.1:5000/main.dart.js:34824:14 acd@http://127.0.0.1:5000/main.dart.js:113977:3 bmB@http://127.0.0.1:5000/main.dart.js:34131:3 b6P@http://127.0.0.1:5000/main.dart.js:34133:20 aB@http://127.0.0.1:5000/main.dart.js:111242:7 J1@http://127.0.0.1:5000/main.dart.js:91694:14 fA@http://127.0.0.1:5000/main.dart.js:91664:6.....

Not that useful tho.

If someone could help us, it'd be amazing :)

Z3ZEL avatar Mar 15 '24 17:03 Z3ZEL

@Z3ZEL deploying to production with a workflow is solving the issue.

droidbg avatar Mar 17 '24 15:03 droidbg

Same here. Suspecting CORS to be a problem.

ReinisSprogis avatar Mar 18 '24 20:03 ReinisSprogis

Hello there ! Having the same issue, what did you guys do (@droidbg and @ReinisSprogis) to fix it ?

romain-girou avatar Mar 20 '24 16:03 romain-girou

Well fixed it myself, looks like it's link to the renderer used to build the web. I was using the default CanvasKit and I build and deploy using the html and deployed and it works. the command to build with html : flutter build web --web-renderer html

romain-girou avatar Mar 20 '24 16:03 romain-girou

@romain-girou html renderer isn't recomended. Low performance. I just needed embeded iframe youtube video. So i made my own widget that is doing just that.

ReinisSprogis avatar Mar 20 '24 16:03 ReinisSprogis

@ReinisSprogis it would be helpful if you could share your code of the widget, thanks.

droidbg avatar Mar 20 '24 18:03 droidbg

@droidbg @romain-girou

import 'package:flutter/material.dart';
import 'package:web/web.dart' as web;
import 'dart:ui_web' as ui;

import 'package:youtube_parser/youtube_parser.dart';

class YoutubeVideoIFrame extends StatefulWidget {
  const YoutubeVideoIFrame({super.key, required this.videoURL});
  final String videoURL;
  @override
  State<YoutubeVideoIFrame> createState() => _YoutubeVideoIFrameState();
}

class _YoutubeVideoIFrameState extends State<YoutubeVideoIFrame> {
  @override
  void initState() {
    super.initState();
    String? id = getIdFromUrl(widget.videoURL);
    if (id != null) {
      ui.platformViewRegistry.registerViewFactory(
          'youtube_player_${widget.videoURL}',
          (int viewId) => web.HTMLIFrameElement()
            ..style.width = '100%'
            ..style.height = '100%'
            ..allowFullscreen = true
            ..src = 'https://www.youtube.com/embed/${id}'
            ..style.border = 'none');
    }
  }

  @override
  Widget build(BuildContext context) {
    return HtmlElementView(viewType: 'youtube_player_${widget.videoURL}');
  }
}

ReinisSprogis avatar Mar 20 '24 18:03 ReinisSprogis

@superman-danny @droidbg I found the solution in this link. https://github.com/sarbagyastha/youtube_player_flutter/issues/819#issuecomment-1650611000

dev210202 avatar Mar 24 '24 07:03 dev210202

Is it works? Becaus a I get this error:

Refused to display 'https://www.youtube.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'. Captura de pantalla 2024-06-10 a las 8 40 18

natouralDS avatar Jun 10 '24 06:06 natouralDS