flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.63k stars 27.35k forks source link

FATAL EXCEPTION: main java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.DisplayAdjustments android.view.Display.getDisplayAdjustments()' on a null object reference #47154

Closed insinfo closed 4 years ago

insinfo commented 4 years ago

i'm having this problem with my app, when i full screen the app in a view with a scaffold and a webview widget playing a video embed from facebook the app closes unexpectedly, the phone is a xiaomi redmi note 6.

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.9.1+hotfix.6, on Microsoft Windows [versão 10.0.18362.535], locale pt-BR)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 3.5)
[√] IntelliJ IDEA Community Edition (version 2019.1)
[!] IntelliJ IDEA Ultimate Edition (version 2018.3)
    X Flutter plugin not installed; this adds Flutter specific functionality.
[√] IntelliJ IDEA Ultimate Edition (version 2019.1)
[√] VS Code (version 1.39.2)
[√] Connected device (1 available)
pubspec.yaml ```yaml name: appsescverao description: Aplicativo do Sesc Verão Rio das Ostras version: 1.0.0+1 environment: sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter flutter_localizations: sdk: flutter cupertino_icons: ^0.1.2 http: ^0.12.0+2 path_provider: ^1.4.0 flutter_advanced_networkimage: ^0.5.0 sqflite: ^1.1.7+2 connectivity: ^0.4.5+3 url_launcher: ^5.2.5 cloud_firestore: ^0.12.10 firebase_auth: ^0.14.0+8 google_sign_in: ^4.0.11 firebase_database: ^3.0.9 rxdart: ^0.22.6 webview_flutter: ^0.3.15+1 auto_size_text: ^2.1.0 flutter_map: ^0.7.3 latlong: ^0.6.1 queries: ^0.1.12 firebase_analytics: ^5.0.6 shared_preferences: ^0.5.4+3 #audioplayers: ^0.13.5 #audio_streams: ^1.0.0+2 dev_dependencies: flutter_test: sdk: flutter intl_translation: ^0.17.7 flutter: uses-material-design: true assets: - assets/logo.png - assets/background.png - assets/background2.png - assets/background3.png - assets/user-avatar.png - assets/logo-pmro-cinza.png - assets/logo-pmro-branco.png - assets/wave-bottom.png - assets/wave-top.png - assets/logo2.png - assets/logo-branca.png fonts: - family: Big Noodle Titling fonts: - asset: fonts/big_noodle_titling.ttf - family: GlosaDisplayW01-Bold fonts: - asset: fonts/glosa_display_w01_bold.ttf - family: BakerieSmoothCondensedMedium fonts: - asset: fonts/BakerieSmoothCondensed-Medium.otf - family: BakerieSmoothBold fonts: - asset: fonts/BakerieSmooth-Bold.otf - family: iconsmind fonts: - asset: fonts/iconsmind.ttf ```
code sample ```dart import 'package:flutter/material.dart'; import '../widgets/diagonally_cut_colored_image.dart'; import '../app_settings.dart'; import '../style.dart'; import 'package:webview_flutter/webview_flutter.dart'; import '../widgets/appbar_search.dart'; import '../strings.dart'; import 'package:path_provider/path_provider.dart'; import 'package:flutter/services.dart'; import 'dart:collection'; import 'dart:async'; import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:flutter/gestures.dart'; import 'dart:io' show Platform; class LivePage extends StatefulWidget { @override State createState() { // TODO: implement createState return new LivePageState(); } } class LivePageState extends State { BuildContext _ctx; static const BACKGROUND_IMAGE = 'assets/sobreHeader.jpg'; //static const url = "https://www.riodasostras.rj.gov.br/live-app-jazz-e-blues-2019/"; static const url = "https://appsescverao.firebaseapp.com/#/livePublic"; WebViewController _controller; Size preferredSize; bool isFullscreen = false; bool isVisibilityFullscreenBtn = true; Timer _timer; Widget _buildAvatar() { return Container( width: double.infinity, height: 120, padding: EdgeInsets.fromLTRB(0, 0, 0, 0), child: Image.asset('assets/logoJazz.png'), ); } Widget _header(BuildContext context) { var theme = Theme.of(context); var textTheme = theme.textTheme; var screenWidth = MediaQuery.of(context).size.width; return Stack( children: [ Container( child: Image.asset( BACKGROUND_IMAGE, width: screenWidth, height: 200, fit: BoxFit.cover, ), ), Container( width: screenWidth, height: 200, color: Color.fromRGBO(30, 97, 145, .7), ), Align( alignment: FractionalOffset.bottomCenter, heightFactor: 1.4, child: Column( children: [ _buildAvatar(), ], ), ), Positioned( top: 26.0, left: 4.0, child: BackButton( color: Colors.white, ), ), ], ); } background() { return Container( width: double.infinity, height: double.infinity, decoration: BoxDecoration( //color: Color.fromRGBO(50, 50, 50, 1) image: DecorationImage( image: AssetImage('assets/background.png'), fit: BoxFit.cover, ), ), child: Container( //color: Color.fromRGBO(103, 189, 211, 0.5), ), ); } appBar() { return SearchAppBar( showSearch: false, title: AppStrings.liveTitle, onKeypress: (searchString) {}, ); } List _buildContent() { var l = new List(); //background page l.add(background()); //lista l.add( Positioned( top: 0, left: 0.0, right: 0.0, bottom: 0, child: Scaffold( appBar: !isFullscreen ? appBar() : null, backgroundColor: Colors.transparent, body: GestureDetector( onDoubleTap: () { print("sad"); setState(() { isVisibilityFullscreenBtn = true; hideFullscreenBtn(); }); }, child: WebView( onWebViewCreated: (WebViewController webViewController) { _controller = webViewController; }, javascriptMode: JavascriptMode.unrestricted, initialUrl: url, ), ), ), ), ); if (Platform.isAndroid) { if (isVisibilityFullscreenBtn) { l.add( Positioned( bottom: 30, right: 30, child: Material( color: Color.fromRGBO(255, 255, 255, 0.5), borderRadius: BorderRadius.all(Radius.circular(50)), child: InkWell( child: Container( padding: EdgeInsets.fromLTRB(16, 16, 16, 16), child: Icon(Icons.fullscreen), ), onTap: () { setState(() { if (!isFullscreen) { isFullscreen = true; SystemChrome.setEnabledSystemUIOverlays([]); hideFullscreenBtn(); } else { isFullscreen = false; SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); } }); }), )), ); } } return l; } hideFullscreenBtn() async { _timer = new Timer(const Duration(milliseconds: 5000), () { setState(() { if (isFullscreen) isVisibilityFullscreenBtn = false; }); }); } @override Widget build(BuildContext context) { _ctx = context; return Stack( fit: StackFit.expand, children: _buildContent(), ); } } ```
logs ```console V/AudioTrack( 7828): obtainBuffer(1922) returned 326 = 322 + 4 err 0 V/AudioTrack( 7828): obtainBuffer(1922) returned 326 = 322 + 4 err 0 V/AudioTrack( 7828): obtainBuffer(1600) returned 4 = 4 + 0 err 0 V/AudioTrack( 7828): obtainBuffer(1596) returned 0 = 0 + 0 err -11 V/AudioTrack( 7828): obtainBuffer(1596) returned 3840 = 1596 + 2244 err 0 V/AudioTrack( 7828): obtainBuffer(1922) returned 2244 = 1922 + 322 err 0 V/AudioTrack( 7828): obtainBuffer(1922) returned 322 = 322 + 0 err 0 V/AudioTrack( 7828): obtainBuffer(1922) returned 322 = 322 + 0 err 0 V/AudioTrack( 7828): obtainBuffer(1600) returned 0 = 0 + 0 err -11 V/AudioTrack( 7828): obtainBuffer(1600) returned 3840 = 252 + 3588 err 0 V/AudioTrack( 7828): obtainBuffer(1348) returned 3588 = 1348 + 2240 err 0 V/AudioTrack( 7828): obtainBuffer(1922) returned 2240 = 1922 + 318 err 0 V/AudioTrack( 7828): obtainBuffer(1922) returned 318 = 318 + 0 err 0 D/ ( 7828): PlayerBase::stop() from IPlayer D/AudioTrack( 7828): stop() called with 1543366 frames delivered W/cr_MediaCodecBridge( 7828): Releasing: OMX.qcom.video.decoder.avc W/ContentCatcher( 7828): Failed to notify a WebView D/SurfaceUtils( 7828): disconnecting from surface 0x7552c22010, reason disconnectFromSurface W/cr_MediaCodecBridge( 7828): Codec released W/Looper ( 7828): Slow Looper main: doFrame is 356ms late because of 4 msg, msg 1 took 82ms (h=android.view.Choreographer$FrameHandler c=android.view.Choreographer$FrameDisplayEventReceiver) D/AndroidRuntime( 7828): Shutting down VM E/AndroidRuntime( 7828): FATAL EXCEPTION: main E/AndroidRuntime( 7828): Process: br.gov.rj.riodasostras.appsescverao, PID: 7828 E/AndroidRuntime( 7828): java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.DisplayAdjustments android.view.Display.getDisplayAdjustments()' on a null object reference E/AndroidRuntime( 7828): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1788) E/AndroidRuntime( 7828): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1532) E/AndroidRuntime( 7828): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7419) E/AndroidRuntime( 7828): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1092) E/AndroidRuntime( 7828): at android.view.Choreographer.doCallbacks(Choreographer.java:888) E/AndroidRuntime( 7828): at android.view.Choreographer.doFrame(Choreographer.java:819) E/AndroidRuntime( 7828): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1078) E/AndroidRuntime( 7828): at android.os.Handler.handleCallback(Handler.java:873) E/AndroidRuntime( 7828): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 7828): at android.os.Looper.loop(Looper.java:201) E/AndroidRuntime( 7828): at android.app.ActivityThread.main(ActivityThread.java:6810) E/AndroidRuntime( 7828): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 7828): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) E/AndroidRuntime( 7828): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) V/AudioTrack( 7828): getMinFrameCount=3844: afFrameCount=1920, afSampleRate=48000, afLatency=80 I/Process ( 7828): Sending signal. PID: 7828 SIG: 9 ```
smartzhao commented 4 years ago

me too

mayurdhurpate commented 4 years ago

Looks similar to #32608 , #34182 , #26345 , and https://github.com/sarbagyastha/youtube_player_flutter/issues/8

PingShen commented 4 years ago

me too,how can we fix these crashes,so terrible.......

singun-lxd commented 4 years ago

i've found the same problem, only found this crash in huawei device...

Sp4Rx commented 4 years ago

Similar problem here on Redmi note 7 pro

ChessLuo commented 4 years ago

I also found this problem in Redmi note 7 pro

csamprajan commented 4 years ago

Anyone found solution ?

edTheGuy00 commented 4 years ago

@chaitanyamolli1310 this was my workaround https://github.com/flutter/flutter/issues/26345#issuecomment-606633903

insinfo commented 4 years ago

@edTheGuy00 Well this is not exactly a solution to the bug, but it works as a palliative solution

xuweishun commented 4 years ago

i'm having this problem with my app, when i full screen the app in a view with a scaffold and a webview widget playing a video embed from facebook the app closes unexpectedly, the phone is a xiaomi redmi note 6.

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.9.1+hotfix.6, on Microsoft Windows [versão 10.0.18362.535], locale pt-BR)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
[√] Android Studio (version 3.5)
[√] IntelliJ IDEA Community Edition (version 2019.1)
[!] IntelliJ IDEA Ultimate Edition (version 2018.3)
    X Flutter plugin not installed; this adds Flutter specific functionality.
[√] IntelliJ IDEA Ultimate Edition (version 2019.1)
[√] VS Code (version 1.39.2)
[√] Connected device (1 available)

pubspec.yaml code sample logs

Did you find a solution ?

Hixie commented 4 years ago

cc @GaryQian Any chance you can take a look at this one? Thanks!

GaryQian commented 4 years ago

Simple repro was posted in https://github.com/flutter/flutter/issues/26345

xster commented 4 years ago

Merging this into #26345. Please reopen if not correct.

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.