Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown when ScrollPosition pixels != null #31413

Closed
sometime-rock opened this issue Apr 22, 2019 · 5 comments
Closed

Exception thrown when ScrollPosition pixels != null #31413

sometime-rock opened this issue Apr 22, 2019 · 5 comments
Labels
waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@sometime-rock
Copy link

sometime-rock commented Apr 22, 2019

Logs

I/flutter (27216): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (27216): The following assertion was thrown while finalizing the widget tree:
I/flutter (27216): 'package:flutter/src/widgets/scroll_position.dart': Failed assertion: line 687 pos 12: 'pixels !=
I/flutter (27216): null': is not true.

@shihaohong
Copy link
Contributor

shihaohong commented Apr 22, 2019

Could you share some context as to when this is happening? I believe it may be related to #18756, which I'm currently working on a fix for

@shihaohong
Copy link
Contributor

(Also, please follow the guidelines on information to share when submitting issues, it really helps with quickly identifying and solving the issue ^_^)

@HansMuller HansMuller added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 22, 2019
@shihaohong shihaohong changed the title I/flutter (27216): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter (27216): The following assertion was thrown while finalizing the widget tree: I/flutter (27216): 'package:flutter/src/widgets/scroll_position.dart': Failed assertion: line 687 pos 12: 'pixels != I/flutter (27216): null': is not true. Exception thrown when ScrollPosition pixels != null Apr 24, 2019
@no-response
Copy link

no-response bot commented May 13, 2019

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
Thanks for your contribution.

@no-response no-response bot closed this as completed May 13, 2019
@keronei
Copy link

keronei commented May 17, 2019

A beginner here.
Had the same issue with an app I have been working on, here is the actual stack trace:

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter ( 3338): The following assertion was thrown while finalizing the widget tree: I/flutter ( 3338): 'package:flutter/src/widgets/scroll_position.dart': Failed assertion: line 687 pos 12: 'pixels != I/flutter ( 3338): null': is not true. I/flutter ( 3338): Either the assertion indicates an error in the framework itself, or we should provide substantially I/flutter ( 3338): more information in this error message to help you determine and fix the underlying cause. I/flutter ( 3338): In either case, please report this assertion by filing a bug on GitHub: I/flutter ( 3338): https://github.com/flutter/flutter/issues/new?template=BUG.md I/flutter ( 3338): When the exception was thrown, this was the stack: I/flutter ( 3338): #2 ScrollPosition.dispose (package:flutter/src/widgets/scroll_position.dart:687:12) I/flutter ( 3338): #3 ScrollPositionWithSingleContext.dispose (package:flutter/src/widgets/scroll_position_with_single_context.dart:257:11) I/flutter ( 3338): #4 ScrollableState.dispose (package:flutter/src/widgets/scrollable.dart:367:14) I/flutter ( 3338): #5 StatefulElement.unmount (package:flutter/src/widgets/framework.dart:3921:12) I/flutter ( 3338): #6 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1696:13) I/flutter ( 3338): #7 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #8 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #9 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #10 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #11 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #12 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #13 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #14 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #15 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #16 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #17 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #18 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #19 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #20 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4970:16) I/flutter ( 3338): #21 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #22 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #23 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #24 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #25 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #26 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #27 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #28 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #29 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #30 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #31 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #32 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #33 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #34 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #35 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4970:16) I/flutter ( 3338): #36 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #37 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #38 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #39 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #40 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #41 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #42 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #43 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #44 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #45 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #46 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #47 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4869:14) I/flutter ( 3338): #48 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #49 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #50 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #51 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #52 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #53 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:4869:14) I/flutter ( 3338): #54 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #55 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #56 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #57 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #58 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #59 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #60 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #61 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #62 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #63 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #64 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #65 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #66 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #67 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #68 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #69 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #70 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #71 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #72 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #73 _InactiveElements._unmount.<anonymous closure> (package:flutter/src/widgets/framework.dart:1694:7) I/flutter ( 3338): #74 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3775:14) I/flutter ( 3338): #75 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1692:13) I/flutter ( 3338): #76 ListIterable.forEach (dart:_internal/iterable.dart:39:13) I/flutter ( 3338): #77 _InactiveElements._unmountAll (package:flutter/src/widgets/framework.dart:1705:25) I/flutter ( 3338): #78 BuildOwner.finalizeTree.<anonymous closure> (package:flutter/src/widgets/framework.dart:2363:27) I/flutter ( 3338): #79 BuildOwner.lockState (package:flutter/src/widgets/framework.dart:2195:15) I/flutter ( 3338): #80 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2362:7) I/flutter ( 3338): #81 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:702:18) I/flutter ( 3338): #82 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:275:5) I/flutter ( 3338): #83 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1012:15) I/flutter ( 3338): #84 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:952:9) I/flutter ( 3338): #85 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:773:7) I/flutter ( 3338): #94 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19) I/flutter ( 3338): #95 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5) I/flutter ( 3338): #96 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:171:12) I/flutter ( 3338): (elided 10 frames from class _AssertionError, package dart:async, and package dart:async-patch) I/flutter ( 3338): ════════════════════════════════════════════════════════════════════════════════════════════════════

The app doesn't crash but this trace is seen from the run console. I filtered the tree from children up and closed on something that did resulted in the crash not happening again.

In my scenario, my app had two events that needed to run during the first launch and marked as complete, this were the introduction pages and location setup. In the main.dart file, I had two variables:

bool isFirstRun = true;
bool isFirstRunIntro = true;

While painting the MaterialApp, I'd do it conditionally:

home: isFirstRunIntro
                ? MySplashScreen()
                : isFirstRun
                    ? StartUp(model: _model) //sets up user location
                    : Scaffold(
                        body: ...

Then on the model, I had a function that persisted the values in sharedprefs and would look up on them by overriding the initState on the same file.
The function getting the values returned something like:
return {'loc' :settings.getBool("hasRun"), 'hasRunIntro' : settings.getBool("hasRunIntro")};
Once the results were in, I'd call another function to update the variables like this:

setUp(Map<String, dynamic> stat) {
  if (stat['loc'] == null) {
    setState(() {
      isFirstRun = true;
    });
  } else {
    setState(() {
      isFirstRun = false;
    });
  }
  if (stat['hasRunIntro'] == null) {
    setState(() {
      isFirstRunIntro = true;
    });
  } else {
    setState(() {
      isFirstRunIntro = false;
    });
  }
}

Assuming that if the app was running for the first time, the values would obviously return null and the next time, it would have a true(Because I did set them to true after every segment was completed->intro & location setup).

I realised that defaulting the values to true(of variables), would mean that every other time the app starts, it would start playing the intro just before the result from sharedprefs arrives, which in my opinion, allowed a short window period that rendered null pixels(in some way) while switching to homepage after realising that the intro should not come to stage - withdrawing it just before it's painted.

My solution was to default the variables to false , then when the results would come in, it would do setState with 'false' results which means there's no windows for null pixels.

I tried to use a FutureBuilder but it seems to take a while to get the results and display while switching tabs, which resulted in a black screen for half a second every time I switch tabs.

In summary, by initialising the variables to true, everything seems to work jus fine.

bool isFirstRun = true;
bool isFirstRunIntro = true;

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
Development

No branches or pull requests

4 participants