TryImpossible / flutter_web_optimizer

A optimization tools for flutter web, solved web page loading slow and browser cache problem.
BSD 3-Clause "New" or "Revised" License
92 stars 14 forks source link

大佬,canvaskit渲染模式下报错 #26

Closed Pianzhous closed 8 months ago

Pianzhous commented 1 year ago

大佬,是不支持canvaskit渲染模式吗?报了这个错 image

TryImpossible commented 1 year ago

目前不支持canvaskit渲染模式

Pianzhous commented 1 year ago

好的,谢谢大佬

liyingte998 commented 1 year ago

近期考虑支持canvaskit吗?flutter_web_optimizer 1.1.12 ;Flutter 3.3.10可以运行canvaskit

TryImpossible commented 1 year ago

@liyingte998 ,周末看下

navyzhou926 commented 9 months ago

@liyingte998 ,周末看下

大佬有时间解决下canvaskit兼容问题不,flutter3.16及以后版本

t0uh33d commented 9 months ago

@TryImpossible why does the code give issues when it comes to canvaskit rendering, any root cause problem?

navyzhou926 commented 9 months ago

@TryImpossible why does the code give issues when it comes to canvaskit rendering, any root cause problem?

@TryImpossible 把项目中的flutter3.10的flutter.js换成flutter3.16的打包版本中的flutter.js修改下,canvaskit是可以用的,需要帮忙尽快支持到项目中

t0uh33d commented 9 months ago

@TryImpossiblewhy does the code give issues when it comes to canvaskit rendering, any root cause problem?

@TryImpossibleReplace the flutter.js of flutter3.10 in the project with the flutter.js in the packaged version of flutter3.16. After modification, canvaskit can be used. I need help to support it in the project as soon as possible.

could you please share the flutter.js file that you may have modified and replaced?

navyzhou926 commented 9 months ago

@TryImpossiblewhy does the code give issues when it comes to canvaskit rendering, any root cause problem?

@TryImpossibleReplace the flutter.js of flutter3.10 in the project with the flutter.js in the packaged version of flutter3.16. After modification, canvaskit can be used. I need help to support it in the project as soon as possible.

could you please share the flutter.js file that you may have modified and replaced?

1、flutter build web打包后,将flutter.js单独保存到临时目录 2、执行flutter_web_optimizer生成相关文件 3、将第1步打包生成的flutter.js替换第2步flutter_web_optimizer自动生成的flutter.js,然后修改flutter.js文件里的main.dart.js引用的生成的hash文件名,就可以了 4、canvaskit打包运行可能flutter_web_optimizer引用的flutter.js不是新版本的,所以可能导致打包后运行报错,建议项目作者抽空兼容下flutter3.16

TryImpossible commented 9 months ago

@Pianzhous @navyzhou926 @liyingte998 ,1.4.0版本适配flutter 3.16版本 ,支持canvaskit模式

TryImpossible commented 9 months ago

@TryImpossiblewhy does the code give issues when it comes to canvaskit rendering, any root cause problem?

@TryImpossibleReplace the flutter.js of flutter3.10 in the project with the flutter.js in the packaged version of flutter3.16. After modification, canvaskit can be used. I need help to support it in the project as soon as possible.

could you please share the flutter.js file that you may have modified and replaced?

@t0uh33d ,https://github.com/TryImpossible/flutter_web_optimizer/blob/main/lib/src/optimize/flutter.js.dart

TryImpossible commented 9 months ago

@TryImpossible why does the code give issues when it comes to canvaskit rendering, any root cause problem?

@t0uh33d ,you could need flutter_web_optimizer 1.4.0 version

navyzhou926 commented 8 months ago

@Pianzhous @navyzhou926 @liyingte998 ,1.4.0版本适配flutter 3.16版本 ,支持canvaskit模式

执行flutter_web_optimizer报错

环境信息: Flutter (Channel stable, 3.16.9, on macOS 14.2.1 23C71 darwin-arm64, locale zh-Hans-CN) • Flutter version 3.16.9 on channel stable at /Users/navyzhou/Projects/Library/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 41456452f2 (4 weeks ago), 2024-01-25 10:06:23 -0800 • Engine revision f40e976bed • Dart version 3.2.6 • DevTools version 2.28.5

执行flutter_web_optimizer报错信息(使用html和canvaskit打包都报错): navyzhou@MacBook:~/git/flutter_test$ dart run flutter_web_optimizer optimize --asset-base ./ --enable-pwa false Building package executable... Built flutter_web_optimizer:flutter_web_optimizer. start web optimize hashing file: /Users/navyzhou/git/flutter_test/build/web/icons/Icon-192.png hashed file name: Icon-192.ac9a721a.png hashing file: /Users/navyzhou/git/flutter_test/build/web/icons/Icon-maskable-192.png hashed file name: Icon-maskable-192.c457ef57.png hashing file: /Users/navyzhou/git/flutter_test/build/web/icons/Icon-maskable-512.png hashed file name: Icon-maskable-512.301a7604.png hashing file: /Users/navyzhou/git/flutter_test/build/web/icons/Icon-512.png Unhandled exception: Invalid argument (Not a byte value at index 1: 0x-5c): _Int8ArrayView

0 _Base64Encoder.encodeChunk (dart:convert/base64.dart:374:5)

1 _Base64Encoder.encode (dart:convert/base64.dart:328:9)

2 Base64Encoder.convert (dart:convert/base64.dart:243:26)

3 Codec.encode (dart:convert/codec.dart:25:32)

4 OptimizeCommand._hashAssets.hashAssetsDir (package:flutter_web_optimizer/src/optimize/optimize_command.dart:493:30)

5 OptimizeCommand._hashAssets (package:flutter_web_optimizer/src/optimize/optimize_command.dart:579:5)

6 OptimizeCommand.run (package:flutter_web_optimizer/src/optimize/optimize_command.dart:116:5)

#7 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
TryImpossible commented 8 months ago

canvaskit 提供个demo

navyzhou926 commented 8 months ago

canvaskit 提供个demo

找到原因了,base64.encode需要用Uint8List,而不能用Int8List,因为encode的数据只能是0~255,而不能是有符号的,optimize_comand.dart改成如图即可,已验证没有问题了,请帮忙尽快修改 图片

TryImpossible commented 8 months ago

canvaskit 提供个demo

找到原因了,base64.encode需要用Uint8List,而不能用Int8List,因为encode的数据只能是0~255,而不能是有符号的,optimize_comand.dart改成如图即可,已验证没有问题了,请帮忙尽快修改 图片

已修复,请使用1.4.1版本