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 #147

Open
andre-ab opened this issue Mar 12, 2024 · 1 comment
Open

"flutter web" crashes the browser #147

andre-ab opened this issue Mar 12, 2024 · 1 comment

Comments

@andre-ab
Copy link

The code snippet crashes the browser, image over 2 MB, hangs for more than 26s and "save" the image, more or less at the same time, I'm using the ChangeNotifier.
code:

Crop(
         aspectRatio: 3 / 4,
         // When starting to load the image, 
         // the code hangs on this line
         image: controller.newImg!,
         controller: controller.cropController,
        // when saving, the code crashes on this line
         onCropped: (Uint8List img) {
               controller.saveImg(img);
         },
),
                        

open to get the image:


  Future<void> openGetImg() async {
    FilePickerResult? result = await FilePicker.platform.pickFiles(
      type: FileType.image,
    );
    if (result == null) return;
    extensionImg = result.files.first.extension;
   //  load the image for Crop
    newImg = result.files.single.bytes;
    notifyListeners();
  }
  

Save button

ElevatedButton(
  child: Text('Crop it!')
  onPressed: () => controller.cropController.crop(),
),
 
@chooyan-eng
Copy link
Owner

@andre-ab Thank you for using and giving me feedback. I'm struggling with separating the thread to operate cropping, which is quite slow on web. Let me take some time to improve the performance on web, or if you have an idea, consider to override the cropping logic via imageCropper argument.

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