flutter_pdf_render icon indicating copy to clipboard operation
flutter_pdf_render copied to clipboard

Flutter Web - sometimes a graphics heavy pdf draws as a blank page

Open zambetpentru opened this issue 3 years ago • 1 comments

Greetings! To start with thanks for your work on this package. :-)

I noticed some a random issue on one pdf where a particular page would go white until the widget was rebuilt. This could be most easily triggered by resizing the Chrome window. I was able to replicate this with just a PdfPageView widget and in the sample code below. It turns out that when there is a large image in the pdf page (or a couple of smaller ones) that this can happen. Perhaps related to https://github.com/espresso3389/flutter_pdf_render/issues/35

I have created a sample PDF with a large image in it that reliably triggers on Chrome in Windows and Mac. The file is available here https://drive.google.com/file/d/13QwssubETQZhYRMDO6E9OfUBR0pYBoF3/view?usp=sharing Indeed it can be hard to get it to render until you make the window small. Do you have any suggestions how this could be trapped / automatically recovered from?

pdf_render - version: "1.0.12"

minimal code sample

import 'package:flutter/material.dart'; import 'package:pdf_render/pdf_render_widgets.dart';

void main(List<String> args) => runApp(MyApp());

class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); }

class _MyAppState extends State<MyApp> { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( backgroundColor: Colors.grey, body: PdfDocumentLoader.openAsset( 'assets/problemPDF.pdf', pageNumber: 1, pageBuilder: (context, textureBuilder, pageSize) => textureBuilder(), ), ), ); } }

flutter doctor

[√] Flutter (Channel master, 2.5.0-7.0.pre.110, on Microsoft Windows [Version 10.0.17763.2114], locale en-IE) • Flutter version 2.5.0-7.0.pre.110 at C:\Code\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 3572a7e8b7 (3 days ago), 2021-08-17 11:52:05 -0700 • Engine revision 7dc8eba6ae • Dart version 2.15.0 (build 2.15.0-15.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Omega\AppData\Local\Android\sdk • Platform android-30, build-tools 30.0.3 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174) • All Android licenses accepted.

[√] Chrome - develop for the web • CHROME_EXECUTABLE = C:\Code\FlutterTesting\ChromeCORS.bat

[√] Android Studio (version 2020.3) • 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.8+10-b944.6842174)

[√] VS Code (version 1.59.0) • VS Code at C:\Users\Omega\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.23.0

[√] Connected device (2 available) • Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.159 • Edge (web) • edge • web-javascript • Microsoft Edge 92.0.902.73

• No issues found!

zambetpentru avatar Aug 20 '21 16:08 zambetpentru

It appears to be related to multiple parallel redraws happening on the same Texture ID, e.g. particularly when dragging the window:

If I make this blocking and serialized then I can't repeat the issue :-)

await _texture!.extractSubrect(
      width: pixelSize.width.toInt(),
      height: pixelSize.height.toInt(),
      fullWidth: pixelSize.width,
      fullHeight: pixelSize.height,
      backgroundFill: backgroundFill,
      allowAntialiasingIOS: allowAntialiasingIOS,
    );

zambetpentru avatar Nov 04 '23 14:11 zambetpentru