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

"flutter web" crashes the browser #620

Open
andre-ab opened this issue Mar 8, 2024 · 4 comments
Open

"flutter web" crashes the browser #620

andre-ab opened this issue Mar 8, 2024 · 4 comments

Comments

@andre-ab
Copy link

andre-ab commented Mar 8, 2024

The code snippet crashes the browser, how to solve this?
because on the Web I can't get the path but rather the "Uint8List" bytes

Future<Uint8List> converNowImgUint8List(Uint8List image) async {
    var newImg = img.decodeJpg(image);
    var x = img.copyResize(newImg!, width: 240);
    return img.encodePng(x);
}

@brendan-duncan
Copy link
Owner

Can you reduce the problem? Is it the decode? The resize? The encode? Comment out the copyResize and encode, does it crash with just the decode? Then add the encode back, try that; then add the resize.
Does the decode actually return an Image, or null?
How large is the jpeg?

@andre-ab
Copy link
Author

andre-ab commented Mar 10, 2024

in this part of the code: img.decodeJpg(image);
image size: 2.7MB
lock time: Start = 09:56.835, end = 10:25.325
Image type: tested with JPG and PNG

// open with: 
FilePickerResult? result = await FilePicker.platform.pickFiles( );
if (kIsWeb) {
  final extension = result.files.first.extension;
  final fileImg = result.files.single.bytes;
   return await crop.converNowImgUint8List(fileImg!, extension!)
 }
 

file: img_crop.dart

     Future<Uint8List> converNowImgUint8List(
      Uint8List image, String extension) async {
    var newImg;
    switch (extension) {
      case 'png':
        // the code crashes on this line
        newImg = img.decodePng(image);
        break;
      case 'jpg':
        // the code crashes on this line
        newImg = img.decodeJpg(image);
        break;
    }
    final x = img.copyResize(newImg!, width: 240);
    return img.encodePng(x);
  }

@andre-ab
Copy link
Author

Can you reduce the problem? Is it the decode? The resize? The encode? Comment out the copyResize and encode, does it crash with just the decode? Then add the encode back, try that; then add the resize. Does the decode actually return an Image, or null? How large is the jpeg?

Any news about these crashes on flutter web?

@brendan-duncan
Copy link
Owner

brendan-duncan commented Mar 17, 2024

Sorry for the delay. I'm afraid there just isn't enough info here to be able to diagnose the problem. I don't know what would be crashing Flutter in this case. 2.7MB file size is not large. I don't know what the contents of the file are. If it were an invalid jpeg, it shouldn't crash. I have no idea. If you can send me the file I could take a look, but otherwise I don't know.

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

2 participants