Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flutter/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"dialogCancel": "Cancel",
"dialogTitleConfirm": "Confirm?",
"dialogContentOfflineWarning": "Offline mode is enabled but following internet resources are defined in the configuration. Do you want to continue?",
"dialogContentMissingFiles": "The following files don't exist:",
"dialogContentMissingFiles": "MLPerf Mobile needs to download some ML model files used by the various benchmark tests. Some of these files can be fairly large, so we recommend connecting to Wi-Fi before downloading, if possible.\n\nOnce the files are downloaded, they will be cached and can be used to run the benchmark tests repeatedly. You can manage the downloaded model files by going to Resources in the app menu.",
"dialogContentMissingFilesHint": "Please go to the menu Resources to download the missing files.",
"dialogContentChecksumError": "The following files failed checksum validation:",
"dialogContentChecksumErrorHint": "Please go to the menu Resources to clear the cache and download the files again.",
Expand Down
39 changes: 6 additions & 33 deletions flutter/lib/ui/error_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ Future<void> showResourceMissingDialog(
BuildContext context, List<String> messages) async {
final l10n = AppLocalizations.of(context)!;

Icon icon = const Icon(Icons.info_outline, color: Colors.grey, size: 32);
Icon icon =
const Icon(Icons.warning_amber_rounded, color: Colors.amber, size: 32);
Color titleColor = Colors.grey;

await showDialog(
Expand Down Expand Up @@ -164,37 +165,7 @@ Future<void> showResourceMissingDialog(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: Colors.amber.withOpacity(0.2),
borderRadius: BorderRadius.circular(8),
border: Border.all(color: Colors.amber, width: 1),
),
child: Row(
children: [
const Icon(Icons.info_outline, color: Colors.amber),
const SizedBox(width: 10),
Flexible(
child: Text(
l10n.dialogContentMissingFilesHint,
style: const TextStyle(
fontSize: 14,
color: Colors.black87,
),
),
),
],
),
),
const SizedBox(height: 10),
...messages.map((e) => Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
e,
style: const TextStyle(fontSize: 15),
),
)),
Text(l10n.dialogContentMissingFiles),
],
),
),
Expand All @@ -219,7 +190,9 @@ Future<void> showResourceMissingDialog(
Navigator.of(context).pop();
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => const ResourcesScreen(),
builder: (context) => const ResourcesScreen(
autoStart: true,
),
),
);
},
Expand Down
40 changes: 31 additions & 9 deletions flutter/lib/ui/settings/resources_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import 'package:mlperfbench/ui/error_dialog.dart';
import 'package:mlperfbench/ui/nil.dart';

class ResourcesScreen extends StatefulWidget {
const ResourcesScreen({super.key});
final bool autoStart;

const ResourcesScreen({this.autoStart = false, super.key});

@override
State<ResourcesScreen> createState() => _ResourcesScreen();
Expand All @@ -28,24 +30,44 @@ class _ResourcesScreen extends State<ResourcesScreen> {
bool get downloading =>
(state.loadingProgress > 0.0 && state.loadingProgress < 0.999);

@override
void initState() {
if (widget.autoStart) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
await state.loadResources(
downloadMissing: true,
benchmarks: state.activeBenchmarks,
);
if (state.error != null) {
if (!mounted) return;
await showErrorDialog(context, <String>[state.error.toString()]);
// Reset both the error and stacktrace for further operation
state.error = null;
state.stackTrace = null;
}
});

super.initState();
}
}

@override
Widget build(BuildContext context) {
store = context.watch<Store>();
state = context.watch<BenchmarkState>();
l10n = AppLocalizations.of(context)!;

final children = <Widget>[];

for (var benchmark in state.allBenchmarks) {
children.addAll([_listTileBuilder(benchmark), const Divider(height: 20)]);
}
children.addAll([
final children = <Widget>[
_downloadButton(state.allBenchmarks, l10n.resourceDownloadAll),
const SizedBox(height: 20),
for (var benchmark in state.allBenchmarks) ...[
_listTileBuilder(benchmark),
const Divider(height: 20),
],
_downloadProgress(),
_downloadButton(state.allBenchmarks, l10n.resourceDownloadAll),
const SizedBox(height: 20),
_clearCacheButton(),
]);
];

return Scaffold(
appBar: AppBar(title: Text(l10n.menuResources)),
Expand Down
Loading