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

[Bug report] Exception: Image upload failed due to loss of GPU access. on flutter 3.27.1 #724

Open
yqritc opened this issue Dec 24, 2024 · 5 comments

Comments

@yqritc
Copy link

yqritc commented Dec 24, 2024

Version

9.0.7

Platforms

iOS

Device Model

iPhone 16 (iOS 18.1) simulator

flutter info

Flutter version 3.27.1
Dart version 3.6.0

How to reproduce?

  1. Launch app by using example code
  2. Press next icon on AppBar.
  3. Move to background
  4. Wait a few seconds, and you will see a lot of error log on console
  5. Launch app again and back to first page
  6. Some images are not displayed

The error does not occur on Android.
Also if we use Image.network instead of ExtendedImage.network, no error occurs.

Logs

======== Exception caught by image resource service ================================================
The following _Exception was thrown resolving an image frame:
Exception: Image upload failed due to loss of GPU access.

When the exception was thrown, this was the stack: 
Image provider: ExtendedNetworkImageProvider("https://picsum.photos/seed/20/393/200", scale: 1.0)
Image key: ExtendedNetworkImageProvider("https://picsum.photos/seed/20/393/200", scale: 1.0)
====================================================================================================

Example code (optional)

######## main.dart ########
import 'package:extended_image/extended_image.dart';
import 'package:flutter/material.dart';
import 'package:test_ios_images/second_screen.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter 3.27.1 iOS image error'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    final int imageWidth = MediaQuery.sizeOf(context).width.toInt();
    final int imageHeight = 200;
    final urls = List.generate(50, (i) {
      return 'https://picsum.photos/seed/$i/$imageWidth/$imageHeight';
    });

    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
        actions: [
          IconButton(
            icon: const Icon(Icons.navigate_next),
            tooltip: 'Next',
            onPressed: () {
              Navigator.of(context).push(
                MaterialPageRoute(builder: (context) => const SecondScreen()),
              );
            },
          ),
        ],
      ),
      body: ListView.builder(
        itemCount: urls.length,
        // No error occurs when removing cacheExtent
        cacheExtent: MediaQuery.sizeOf(context).height * 5,
        itemBuilder: (context, index) {
          return SizedBox(
            width: double.infinity,
            height: imageHeight.toDouble(),
            // No error occurs when using Image.network instead
            // child: Image.network(urls[index]),
            child: ExtendedImage.network(urls[index]),
          );
        },
      ),
    );
  }
}

######## second_screen.dart ########
import 'package:flutter/material.dart';

class SecondScreen extends StatefulWidget {
  const SecondScreen({super.key});

  @override
  State<SecondScreen> createState() => SecondScreenState();
}

class SecondScreenState extends State<SecondScreen> {
  @override
  Widget build(BuildContext context) {
    return ColoredBox(color: Colors.red);
  }
}

Contact

No response

@zmtzawqlp
Copy link
Member

can't reproduce at my side, and please test it on a real phone

@yqritc
Copy link
Author

yqritc commented Dec 25, 2024

@zmtzawqlp
I also reproduce this issue by using real device, iPhone 14 Pro (iOS 16.6)

@zmtzawqlp
Copy link
Member

@zmtzawqlp I also reproduce this issue by using real device, iPhone 14 Pro (iOS 16.6)

i can't reproduce at my side, real device and simulator

@zmtzawqlp zmtzawqlp reopened this Dec 25, 2024
@wandyers
Copy link

It seems to be related to the operating system. I reproduced this problem on my iPhone 13 (iOS 16.6.1).

@zmtzawqlp
Copy link
Member

zmtzawqlp commented Dec 25, 2024

it seems that flutter/flutter#159397, Image.network also has this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants