flutter_svg icon indicating copy to clipboard operation
flutter_svg copied to clipboard

PersistedOffset: is in an unexpected state. when pop back to route that displayed an svg in the AppBar if the platform is Web

Open ahmed-alhelali opened this issue 2 years ago • 3 comments

Hi everyone!

First of all, thanks a lot for this awesome plugin!

I'm trying to use the flutter_svg to display the icons everywhere in my app, and everything works perfectly if the platform is Android

but!, when the platform is Web and when I try to pop back using "navigator.pop(context)" to a route/screen that shows an SVG in the AppBar(which I use svg_flutter to display) I'm getting this error

```
======== Exception caught by scheduler library =====================================================
The following PersistedSurfaceException was thrown during a scheduler callback:
PersistedOffset: is in an unexpected state.
Expected one of: PersistedSurfaceState.active, PersistedSurfaceState.released
But was: PersistedSurfaceState.pendingRetention

When the exception was thrown, this was the stack: 
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49      throw_
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/html/surface.dart 179:3                        debugAssertSurfaceState
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/html/scene_builder.dart 294:14                 addRetained
packages/flutter/src/rendering/layer.dart 643:14                                                                               [_addToSceneWithRetainedRendering]
packages/flutter/src/rendering/layer.dart 1241:12                                                                              addChildrenToScene
packages/flutter/src/rendering/layer.dart 1378:5                                                                               addToScene
packages/flutter/src/rendering/layer.dart 646:5                                                                                [_addToSceneWithRetainedRendering]
packages/flutter/src/rendering/layer.dart 1241:12                                                                              addChildrenToScene
packages/flutter/src/rendering/layer.dart 1378:5                                                                               addToScene
packages/flutter/src/rendering/layer.dart 646:5                                                                                [_addToSceneWithRetainedRendering]
packages/flutter/src/rendering/layer.dart 1241:12                                                                              addChildrenToScene
packages/flutter/src/rendering/layer.dart 1834:5                                                                               addToScene
packages/flutter/src/rendering/layer.dart 1054:5                                                                               buildScene
packages/flutter/src/rendering/view.dart 231:30                                                                                compositeFrame
packages/flutter/src/rendering/binding.dart 517:18                                                                             drawFrame
packages/flutter/src/widgets/binding.dart 884:13                                                                               drawFrame
packages/flutter/src/rendering/binding.dart 378:5                                                                              [_handlePersistentFrameCallback]
packages/flutter/src/scheduler/binding.dart 1175:15                                                                            [_invokeFrameCallback]
packages/flutter/src/scheduler/binding.dart 1104:9                                                                             handleDrawFrame
packages/flutter/src/scheduler/binding.dart 1015:5                                                                             [_handleDrawFrame]
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/platform_dispatcher.dart 1168:13               invoke
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/platform_dispatcher.dart 219:5                 invokeOnDrawFrame
C:/b/s/w/ir/cache/builder/src/out/host_debug/flutter_web_sdk/lib/_engine/engine/initialization.dart 195:45                     <fn>
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 334:14  _checkAndCall
C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 339:39  dcall
```

this is the code example of the first screen that contains the SVG icon in the AppBar

class FirstScreen extends StatelessWidget {
 const FirstScreen ({Key? key}) : super(key: key);
 @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        elevation: 0.0,
        leading: IconButton(
          onPressed: () {
            Navigator.of(context).pop();
          },
          icon: SvgPicture.asset(
            Constants.arrowBackIcon,
            width: 14,
            height: 14,
            color: Theme.of(context).primaryColor,
          ),
        ),
        centerTitle: true,
        title: Text(
          "Text",
        ),
      ),
    );
  }
}



this is the result of flutter doctor -v
[√] Flutter (Channel stable, 3.3.10, on Microsoft Windows [Version 10.0.22621.1105], locale en-US)
    • Flutter version 3.3.10 on channel stable at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 135454af32 (5 weeks ago), 2022-12-15 07:36:55 -0800
    • Engine revision 3316dd8728
    • Dart version 2.18.6
    • DevTools version 2.15.0

[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at C:\Users\ahmed\AppData\Local\Android\sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.0)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.2.32505.173
    • Windows 10 SDK version 10.0.19041.0

[√] Android Studio (version 2021.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)

[√] IntelliJ IDEA Ultimate Edition (version 2022.1)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2022.1.1
    • Flutter plugin version 70.0.4
    • Dart plugin version 221.5591.58

[√] VS Code (version 1.74.1)
    • VS Code at C:\Users\ahmed\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.56.0

[√] Connected device (5 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
    • Android SDK built for x86 (mobile) • emulator-5556 • android-x86    • Android 10 (API 29) (emulator)
    • Windows (desktop)                  • windows       • windows-x64    • Microsoft Windows [Version 10.0.22621.1105]
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome 108.0.5359.126
    • Edge (web)                         • edge          • web-javascript • Microsoft Edge 109.0.1518.52

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

ahmed-alhelali avatar Jan 17 '23 20:01 ahmed-alhelali

I've got this too, in my case I dont even have to navigate. I just scroll to where the widget is and I see it.

Prn-Ice avatar Mar 30 '23 23:03 Prn-Ice

That's really strange (:

ahmed-alhelali avatar Apr 12 '23 21:04 ahmed-alhelali

I'm getting the similar error,

PersistedOffset: is in an unexpected state. Expected one of: PersistedSurfaceState.active, PersistedSurfaceState.released But was: PersistedSurfaceState.pendingRetention

Seemingly they are related but this happens when I'm scrolling and the color of the svg is changed. if I don't change the original color of the SVG, this won't happen.

Ashkan-Oliaie avatar Oct 19 '23 23:10 Ashkan-Oliaie