Compare commits

...
3 Commits
Author SHA1 Message Date
RarDog 8ad36e2f6b fix: eliminate video player blue screen on desktop with software rendering default and decoder toggle (v3.6.4)
Build and Release / Build Windows x64 (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
2026-09-05 18:48:33 +03:00
RarDog 4aedde9b3f feat: desktop horizontal mouse-wheel scroll & fix PC video player blue screen (v3.6.3)
Build and Release / Build Windows x64 (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
2026-09-05 18:32:45 +03:00
RarDog 5b2c8eb53e fix(perf): memory optimization, prevent OOM on mobile, and completely disable mouse wheel zoom
Build and Release / Build Windows x64 (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
2026-09-05 18:09:58 +03:00
14 changed files with 622 additions and 350 deletions
+2 -1
View File
@@ -5,7 +5,8 @@
<application <application
android:label="Prisma" android:label="Prisma"
android:name="${applicationName}" android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher"
android:largeHeap="true">
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" android:exported="true"
+30
View File
@@ -1,4 +1,34 @@
const prismaChangelog = [ const prismaChangelog = [
PrismaChange(
version: '3.6.4',
title: 'Полное исправление воспроизведения видео на ПК (устранение синего экрана)',
bullets: [
'Программный рендеринг (S/W) по умолчанию для ПК: на десктопных платформах отключен проблемный OpenGL FBO мост аппаратного ускорения, вызывавший синий экран из-за отсутствия или конфликтов драйверов VAAPI/VDPAU в Linux/AppImage.',
'Переключатель декодера H/W / S/W в плеере: на верхней панели управления видеоплеером добавлена кнопка быстрого переключения между аппаратным (H/W) и программным (S/W) декодированием на лету.',
'Отображение постера-превью: под видеоплеером теперь отображается превью-постер на время буферизации, исключая появление пустых областей.',
'Безопасное превью в ленте: предпросмотр видео в карточках постов на ПК также переведен на надежный программный рендерер.',
],
),
PrismaChange(
version: '3.6.3',
title: 'Горизонтальный скролл колесиком мыши на ПК и исправление синего экрана в видеоплеере',
bullets: [
'Горизонтальная прокрутка колесиком мыши в настройках: верхняя панель категорий настроек теперь плавно прокручивается колесиком мыши строго при наведении курсора.',
'Горизонтальная прокрутка колесиком мыши в авторах: полоса любимых авторов и лента их медиа теперь поддерживают быструю прокрутку колесиком мыши при наведении курсора.',
'Устранение «синего экрана» в видеоплеере на ПК: исправлена нативная инициализация MediaKit перед запуском Flutter-движка и настроен оптимальный режим аппаратного ускорения для десктопных платформ.',
],
),
PrismaChange(
version: '3.6.2',
title: 'Комплексная оптимизация памяти на телефоне и ПК, полное отключение зума колесиком',
bullets: [
'Полное отключение масштабирования колесиком мыши: перехвачен внутренний обработчик PointerScrollEvent в интерактивном вьюере, что навсегда исключило нежелательный зум при прокрутке.',
'Предотвращение вылетов на смартфонах (OOM): включен флаг android:largeHeap="true", расширяющий доступный лимит оперативной памяти процесса до 512–1024 МБ.',
'Ограничение аппетита кэша изображений: глобальный ImageCache в Flutter ограничен безопасным лимитом в 180 МБ и 120 изображений (вместо неограниченного роста до 1 ГБ+), неактивные растры своевременно выгружаются сборщиком мусора.',
'Оптимизация декодирования тяжелых артов: полноразмерные изображения с экстремальным разрешением (до 10K+) теперь безопасно декодируются с ограничением memCacheWidth под экран устройства, снижая расход RAM на 80–90%.',
'Оптимизация сетки и миниатюр: карточки ленты изолированы в RepaintBoundary для гладкого 120 FPS скролла без паразитных перерисовок, а всем каруселям, аватаркам и мозаикам заданы строгие границы кэширования.',
],
),
PrismaChange( PrismaChange(
version: '3.6.1', version: '3.6.1',
title: 'Плавная боковая панель без лагов и отключение зума колесиком', title: 'Плавная боковая панель без лагов и отключение зума колесиком',
@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:ui'; import 'dart:ui';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
@@ -1328,7 +1329,7 @@ class _FavoriteArtistsModalState extends State<_FavoriteArtistsModal> {
} }
} }
class _FavoriteArtistsSection extends ConsumerWidget { class _FavoriteArtistsSection extends StatefulWidget {
const _FavoriteArtistsSection({ const _FavoriteArtistsSection({
required this.favorites, required this.favorites,
required this.selectedKey, required this.selectedKey,
@@ -1344,8 +1345,23 @@ class _FavoriteArtistsSection extends ConsumerWidget {
final ValueChanged<FavoriteArtistItem> onRemoveFavorite; final ValueChanged<FavoriteArtistItem> onRemoveFavorite;
@override @override
Widget build(BuildContext context, WidgetRef ref) { State<_FavoriteArtistsSection> createState() =>
if (favorites.isEmpty) { _FavoriteArtistsSectionState();
}
class _FavoriteArtistsSectionState extends State<_FavoriteArtistsSection> {
final ScrollController _scrollController = ScrollController();
bool _isHovered = false;
@override
void dispose() {
_scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (widget.favorites.isEmpty) {
return Padding( return Padding(
padding: const EdgeInsets.fromLTRB(16, 4, 16, 8), padding: const EdgeInsets.fromLTRB(16, 4, 16, 8),
child: _ArtistsLiquidCard( child: _ArtistsLiquidCard(
@@ -1368,9 +1384,9 @@ class _FavoriteArtistsSection extends ConsumerWidget {
); );
} }
final selected = favorites.firstWhere( final selected = widget.favorites.firstWhere(
(f) => f.key == selectedKey, (f) => f.key == widget.selectedKey,
orElse: () => favorites.first, orElse: () => widget.favorites.first,
); );
return Padding( return Padding(
@@ -1385,14 +1401,14 @@ class _FavoriteArtistsSection extends ConsumerWidget {
const Icon(Icons.star_rounded, color: Colors.amber, size: 20), const Icon(Icons.star_rounded, color: Colors.amber, size: 20),
const SizedBox(width: 6), const SizedBox(width: 6),
Text( Text(
'Любимые авторы (${favorites.length})', 'Любимые авторы (${widget.favorites.length})',
style: Theme.of(context).textTheme.titleSmall?.copyWith( style: Theme.of(context).textTheme.titleSmall?.copyWith(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
), ),
const Spacer(), const Spacer(),
TextButton( TextButton(
onPressed: () => onOpenArtist(selected), onPressed: () => widget.onOpenArtist(selected),
style: TextButton.styleFrom( style: TextButton.styleFrom(
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
padding: const EdgeInsets.symmetric(horizontal: 8), padding: const EdgeInsets.symmetric(horizontal: 8),
@@ -1409,21 +1425,42 @@ class _FavoriteArtistsSection extends ConsumerWidget {
], ],
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
SizedBox( MouseRegion(
onEnter: (_) => _isHovered = true,
onExit: (_) => _isHovered = false,
child: Listener(
onPointerSignal: (event) {
if (!_isHovered ||
event is! PointerScrollEvent ||
!_scrollController.hasClients) {
return;
}
final delta = event.scrollDelta.dy != 0
? event.scrollDelta.dy
: event.scrollDelta.dx;
if (delta == 0) return;
final target = (_scrollController.offset + delta * 1.5).clamp(
0.0,
_scrollController.position.maxScrollExtent,
);
_scrollController.jumpTo(target);
},
child: SizedBox(
height: 88, height: 88,
child: ListView.separated( child: ListView.separated(
controller: _scrollController,
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: favorites.length, itemCount: widget.favorites.length,
separatorBuilder: (_, __) => const SizedBox(width: 10), separatorBuilder: (_, __) => const SizedBox(width: 10),
itemBuilder: (context, index) { itemBuilder: (context, index) {
final fav = favorites[index]; final fav = widget.favorites[index];
final isSelected = fav.key == selected.key; final isSelected = fav.key == selected.key;
final sColor = _serviceColor(fav.service); final sColor = _serviceColor(fav.service);
return InkWell( return InkWell(
borderRadius: BorderRadius.circular(16), borderRadius: BorderRadius.circular(16),
onTap: () => onSelect(fav), onTap: () => widget.onSelect(fav),
child: AnimatedContainer( child: AnimatedContainer(
duration: const Duration(milliseconds: 200), duration: const Duration(milliseconds: 200),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6), padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
@@ -1474,6 +1511,8 @@ class _FavoriteArtistsSection extends ConsumerWidget {
fav.avatarUrl!.isNotEmpty fav.avatarUrl!.isNotEmpty
? CachedNetworkImage( ? CachedNetworkImage(
imageUrl: fav.avatarUrl!, imageUrl: fav.avatarUrl!,
memCacheWidth: 120,
memCacheHeight: 120,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => const Icon( placeholder: (_, __) => const Icon(
Icons.person_rounded, Icons.person_rounded,
@@ -1516,6 +1555,8 @@ class _FavoriteArtistsSection extends ConsumerWidget {
}, },
), ),
), ),
),
),
const SizedBox(height: 6), const SizedBox(height: 6),
_FavoriteArtistMediaStrip(artist: selected), _FavoriteArtistMediaStrip(artist: selected),
], ],
@@ -1525,18 +1566,34 @@ class _FavoriteArtistsSection extends ConsumerWidget {
} }
} }
class _FavoriteArtistMediaStrip extends ConsumerWidget { class _FavoriteArtistMediaStrip extends ConsumerStatefulWidget {
const _FavoriteArtistMediaStrip({required this.artist}); const _FavoriteArtistMediaStrip({required this.artist});
final FavoriteArtistItem artist; final FavoriteArtistItem artist;
@override @override
Widget build(BuildContext context, WidgetRef ref) { ConsumerState<_FavoriteArtistMediaStrip> createState() =>
_FavoriteArtistMediaStripState();
}
class _FavoriteArtistMediaStripState
extends ConsumerState<_FavoriteArtistMediaStrip> {
final ScrollController _scrollController = ScrollController();
bool _isHovered = false;
@override
void dispose() {
_scrollController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final query = ArtistWorkQuery( final query = ArtistWorkQuery(
providerId: artist.providerId, providerId: widget.artist.providerId,
service: artist.service, service: widget.artist.service,
artistId: artist.id, artistId: widget.artist.id,
artistName: artist.name, artistName: widget.artist.name,
); );
final asyncPosts = ref.watch(artistPostsProvider(query)); final asyncPosts = ref.watch(artistPostsProvider(query));
@@ -1564,9 +1621,30 @@ class _FavoriteArtistMediaStrip extends ConsumerWidget {
), ),
); );
} }
return SizedBox( return MouseRegion(
onEnter: (_) => _isHovered = true,
onExit: (_) => _isHovered = false,
child: Listener(
onPointerSignal: (event) {
if (!_isHovered ||
event is! PointerScrollEvent ||
!_scrollController.hasClients) {
return;
}
final delta = event.scrollDelta.dy != 0
? event.scrollDelta.dy
: event.scrollDelta.dx;
if (delta == 0) return;
final target = (_scrollController.offset + delta * 1.5).clamp(
0.0,
_scrollController.position.maxScrollExtent,
);
_scrollController.jumpTo(target);
},
child: SizedBox(
height: 96, height: 96,
child: ListView.separated( child: ListView.separated(
controller: _scrollController,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: posts.length.clamp(0, 15), itemCount: posts.length.clamp(0, 15),
separatorBuilder: (_, __) => const SizedBox(width: 8), separatorBuilder: (_, __) => const SizedBox(width: 8),
@@ -1599,6 +1677,8 @@ class _FavoriteArtistMediaStrip extends ConsumerWidget {
imageUrl: post.previewUrl.isNotEmpty imageUrl: post.previewUrl.isNotEmpty
? post.previewUrl ? post.previewUrl
: post.sampleUrl, : post.sampleUrl,
memCacheWidth: 200,
memCacheHeight: 200,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => ColoredBox( placeholder: (_, __) => ColoredBox(
color: Theme.of(context) color: Theme.of(context)
@@ -1635,6 +1715,8 @@ class _FavoriteArtistMediaStrip extends ConsumerWidget {
); );
}, },
), ),
),
),
); );
}, },
), ),
@@ -1706,6 +1788,8 @@ class _ArtistAvatar extends StatelessWidget {
? fallback ? fallback
: CachedNetworkImage( : CachedNetworkImage(
imageUrl: artist.avatarUrl!, imageUrl: artist.avatarUrl!,
memCacheWidth: 140,
memCacheHeight: 140,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => fallback, placeholder: (_, __) => fallback,
errorWidget: (_, __, ___) => fallback, errorWidget: (_, __, ___) => fallback,
@@ -314,6 +314,8 @@ class _CollectionCard extends ConsumerWidget {
if (urls.length == 1) { if (urls.length == 1) {
return CachedNetworkImage( return CachedNetworkImage(
imageUrl: urls[0], imageUrl: urls[0],
memCacheWidth: 260,
memCacheHeight: 260,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => Container(color: scheme.surfaceContainerHighest), placeholder: (_, __) => Container(color: scheme.surfaceContainerHighest),
errorWidget: (_, __, ___) => Container( errorWidget: (_, __, ___) => Container(
@@ -333,6 +335,8 @@ class _CollectionCard extends ConsumerWidget {
if (i < urls.length) if (i < urls.length)
CachedNetworkImage( CachedNetworkImage(
imageUrl: urls[i], imageUrl: urls[i],
memCacheWidth: 200,
memCacheHeight: 200,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => placeholder: (_, __) =>
Container(color: scheme.surfaceContainerHighest), Container(color: scheme.surfaceContainerHighest),
@@ -1225,6 +1225,8 @@ class _ArtistCard extends StatelessWidget {
), ),
child: CachedNetworkImage( child: CachedNetworkImage(
imageUrl: url, imageUrl: url,
memCacheWidth: 128,
memCacheHeight: 128,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => Container( placeholder: (_, __) => Container(
color: scheme.surfaceContainerHighest, color: scheme.surfaceContainerHighest,
@@ -1155,6 +1155,8 @@ class _NeighborStrip extends StatelessWidget {
imageUrl: post.previewUrl.isNotEmpty imageUrl: post.previewUrl.isNotEmpty
? post.previewUrl ? post.previewUrl
: post.sampleUrl, : post.sampleUrl,
memCacheWidth: 160,
memCacheHeight: 160,
fit: BoxFit.cover, fit: BoxFit.cover,
errorWidget: (_, __, ___) => errorWidget: (_, __, ___) =>
const Center(child: Icon(Icons.broken_image_rounded)), const Center(child: Icon(Icons.broken_image_rounded)),
@@ -4,6 +4,7 @@ import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:media_kit/media_kit.dart'; import 'package:media_kit/media_kit.dart';
@@ -77,6 +78,8 @@ class _PostMediaViewerState extends State<PostMediaViewer>
String? _videoError; String? _videoError;
bool _retriedFormatError = false; bool _retriedFormatError = false;
bool _softwareDecodingFallback = false; bool _softwareDecodingFallback = false;
late bool _useSoftwareDecoding =
Platform.isLinux || Platform.isWindows || Platform.isMacOS;
Timer? _hideTimer; Timer? _hideTimer;
StreamSubscription<String>? _errorSubscription; StreamSubscription<String>? _errorSubscription;
StreamSubscription<Duration>? _positionSubscription; StreamSubscription<Duration>? _positionSubscription;
@@ -108,6 +111,8 @@ class _PostMediaViewerState extends State<PostMediaViewer>
_videoError = null; _videoError = null;
_retriedFormatError = false; _retriedFormatError = false;
_softwareDecodingFallback = false; _softwareDecodingFallback = false;
_useSoftwareDecoding =
Platform.isLinux || Platform.isWindows || Platform.isMacOS;
_imageUrls = _buildImageUrls(widget.post); _imageUrls = _buildImageUrls(widget.post);
_videoUrls = _buildVideoUrls(widget.post); _videoUrls = _buildVideoUrls(widget.post);
if (_isPlayableMedia(widget.post) && _videoUrls.isNotEmpty) { if (_isPlayableMedia(widget.post) && _videoUrls.isNotEmpty) {
@@ -225,6 +230,11 @@ class _PostMediaViewerState extends State<PostMediaViewer>
aspectRatio: widget.post.width > 0 && widget.post.height > 0 aspectRatio: widget.post.width > 0 && widget.post.height > 0
? widget.post.width / widget.post.height ? widget.post.width / widget.post.height
: 16 / 9, : 16 / 9,
previewUrl: widget.post.previewUrl.isNotEmpty
? widget.post.previewUrl
: widget.post.sampleUrl,
isSoftwareDecoding: _useSoftwareDecoding,
onToggleDecoder: _toggleDecoderMode,
controlsVisible: _controlsVisible, controlsVisible: _controlsVisible,
coverVideo: _coverVideo, coverVideo: _coverVideo,
muted: _muted, muted: _muted,
@@ -316,10 +326,16 @@ class _PostMediaViewerState extends State<PostMediaViewer>
), ),
); );
} else { } else {
final mq = MediaQuery.maybeOf(context);
final dpr = mq?.devicePixelRatio ?? 1.5;
final screenWidth = mq?.size.width ?? 1280;
final maxCacheWidth =
(screenWidth * dpr * 1.5).round().clamp(1080, 2560);
image = CachedNetworkImage( image = CachedNetworkImage(
key: ValueKey(url), key: ValueKey(url),
imageUrl: url, imageUrl: url,
httpHeaders: headers, httpHeaders: headers,
memCacheWidth: maxCacheWidth,
fit: BoxFit.contain, fit: BoxFit.contain,
placeholder: (context, url) => placeholder: (context, url) =>
const Center(child: CircularProgressIndicator()), const Center(child: CircularProgressIndicator()),
@@ -437,11 +453,12 @@ class _PostMediaViewerState extends State<PostMediaViewer>
void _initializeVideo() { void _initializeVideo() {
MediaKit.ensureInitialized(); MediaKit.ensureInitialized();
_player = Player(); _player = Player();
final bool enableHw = !_useSoftwareDecoding && !_softwareDecodingFallback;
_controller = VideoController( _controller = VideoController(
_player!, _player!,
configuration: VideoControllerConfiguration( configuration: VideoControllerConfiguration(
enableHardwareAcceleration: !_softwareDecodingFallback, enableHardwareAcceleration: enableHw,
hwdec: _softwareDecodingFallback ? 'no' : 'auto-safe', hwdec: enableHw ? (Platform.isAndroid ? 'auto-safe' : 'auto') : 'no',
), ),
); );
_applyVolume(); _applyVolume();
@@ -516,6 +533,7 @@ class _PostMediaViewerState extends State<PostMediaViewer>
lower.contains('failed to recognize file format'))) { lower.contains('failed to recognize file format'))) {
_retriedFormatError = true; _retriedFormatError = true;
_softwareDecodingFallback = true; _softwareDecodingFallback = true;
_useSoftwareDecoding = true;
_disposeVideo(); _disposeVideo();
await Future<void>.delayed(const Duration(milliseconds: 250)); await Future<void>.delayed(const Duration(milliseconds: 250));
if (mounted) { if (mounted) {
@@ -533,6 +551,7 @@ class _PostMediaViewerState extends State<PostMediaViewer>
_videoIndex = 0; _videoIndex = 0;
_retriedFormatError = false; _retriedFormatError = false;
_softwareDecodingFallback = true; _softwareDecodingFallback = true;
_useSoftwareDecoding = true;
_disposeVideo(); _disposeVideo();
await Future<void>.delayed(const Duration(milliseconds: 150)); await Future<void>.delayed(const Duration(milliseconds: 150));
if (mounted) { if (mounted) {
@@ -540,6 +559,26 @@ class _PostMediaViewerState extends State<PostMediaViewer>
} }
} }
void _toggleDecoderMode() {
setState(() {
_useSoftwareDecoding = !_useSoftwareDecoding;
_softwareDecodingFallback = false;
_retriedFormatError = false;
});
_disposeVideo();
_initializeVideo();
ScaffoldMessenger.maybeOf(context)?.showSnackBar(
SnackBar(
content: Text(
_useSoftwareDecoding
? 'Включено программное декодирование (S/W)'
: 'Включено аппаратное декодирование (H/W)',
),
duration: const Duration(seconds: 2),
),
);
}
void _disposeVideo() { void _disposeVideo() {
_hideTimer?.cancel(); _hideTimer?.cancel();
_errorSubscription?.cancel(); _errorSubscription?.cancel();
@@ -681,6 +720,11 @@ class _PostMediaViewerState extends State<PostMediaViewer>
halfVolume: _halfVolume, halfVolume: _halfVolume,
coverVideo: _coverVideo, coverVideo: _coverVideo,
initialVolume: _currentVolume, initialVolume: _currentVolume,
previewUrl: widget.post.previewUrl.isNotEmpty
? widget.post.previewUrl
: widget.post.sampleUrl,
isSoftwareDecoding: _useSoftwareDecoding,
onToggleDecoder: _toggleDecoderMode,
errorMessage: _videoError, errorMessage: _videoError,
onRetry: _retryVideo, onRetry: _retryVideo,
onChanged: (snapshot) { onChanged: (snapshot) {
@@ -877,6 +921,9 @@ class _FullscreenVideoPage extends StatefulWidget {
required this.halfVolume, required this.halfVolume,
required this.coverVideo, required this.coverVideo,
this.initialVolume = 100.0, this.initialVolume = 100.0,
this.previewUrl,
required this.isSoftwareDecoding,
required this.onToggleDecoder,
required this.errorMessage, required this.errorMessage,
required this.onRetry, required this.onRetry,
required this.onChanged, required this.onChanged,
@@ -891,6 +938,9 @@ class _FullscreenVideoPage extends StatefulWidget {
final bool halfVolume; final bool halfVolume;
final bool coverVideo; final bool coverVideo;
final double initialVolume; final double initialVolume;
final String? previewUrl;
final bool isSoftwareDecoding;
final VoidCallback onToggleDecoder;
final String? errorMessage; final String? errorMessage;
final VoidCallback onRetry; final VoidCallback onRetry;
final ValueChanged<VideoPlaybackSnapshot> onChanged; final ValueChanged<VideoPlaybackSnapshot> onChanged;
@@ -1015,6 +1065,9 @@ class _FullscreenVideoPageState extends State<_FullscreenVideoPage> {
player: widget.player, player: widget.player,
controller: widget.controller, controller: widget.controller,
aspectRatio: widget.aspectRatio, aspectRatio: widget.aspectRatio,
previewUrl: widget.previewUrl,
isSoftwareDecoding: widget.isSoftwareDecoding,
onToggleDecoder: widget.onToggleDecoder,
controlsVisible: _controlsVisible, controlsVisible: _controlsVisible,
coverVideo: _coverVideo, coverVideo: _coverVideo,
muted: _muted, muted: _muted,
@@ -1566,6 +1619,9 @@ class _VideoSurface extends StatefulWidget {
required this.player, required this.player,
required this.controller, required this.controller,
required this.aspectRatio, required this.aspectRatio,
this.previewUrl,
required this.isSoftwareDecoding,
required this.onToggleDecoder,
required this.controlsVisible, required this.controlsVisible,
required this.coverVideo, required this.coverVideo,
required this.muted, required this.muted,
@@ -1590,6 +1646,9 @@ class _VideoSurface extends StatefulWidget {
final Player player; final Player player;
final VideoController controller; final VideoController controller;
final double aspectRatio; final double aspectRatio;
final String? previewUrl;
final bool isSoftwareDecoding;
final VoidCallback onToggleDecoder;
final bool controlsVisible; final bool controlsVisible;
final bool coverVideo; final bool coverVideo;
final bool muted; final bool muted;
@@ -1748,16 +1807,23 @@ class _VideoSurfaceState extends State<_VideoSurface> {
return Stack( return Stack(
fit: StackFit.expand, fit: StackFit.expand,
children: [ children: [
ColoredBox( if (widget.previewUrl != null && widget.previewUrl!.isNotEmpty)
color: Colors.black, Positioned.fill(
child: Video( child: CachedNetworkImage(
imageUrl: widget.previewUrl!,
fit: widget.coverVideo ? BoxFit.cover : BoxFit.contain,
memCacheWidth: 1920,
memCacheHeight: 1080,
),
),
Video(
controller: widget.controller, controller: widget.controller,
fit: widget.coverVideo ? BoxFit.cover : BoxFit.contain, fit: widget.coverVideo ? BoxFit.cover : BoxFit.contain,
fill: Colors.transparent,
controls: null, controls: null,
pauseUponEnteringBackgroundMode: false, pauseUponEnteringBackgroundMode: false,
resumeUponEnteringForegroundMode: false, resumeUponEnteringForegroundMode: false,
), ),
),
if (_currentBrightness < 0.99) if (_currentBrightness < 0.99)
Positioned.fill( Positioned.fill(
child: IgnorePointer( child: IgnorePointer(
@@ -1835,6 +1901,8 @@ class _VideoSurfaceState extends State<_VideoSurface> {
fullscreen: widget.fullscreen, fullscreen: widget.fullscreen,
isLocked: _isLocked, isLocked: _isLocked,
isLandscape: widget.isLandscape, isLandscape: widget.isLandscape,
isSoftwareDecoding: widget.isSoftwareDecoding,
onToggleDecoder: widget.onToggleDecoder,
onToggleOrientation: widget.onToggleOrientation, onToggleOrientation: widget.onToggleOrientation,
onToggleLock: () => setState(() => _isLocked = !_isLocked), onToggleLock: () => setState(() => _isLocked = !_isLocked),
onToggleFit: widget.onToggleFit, onToggleFit: widget.onToggleFit,
@@ -2205,6 +2273,7 @@ class _ZoomableImageState extends State<_ZoomableImage> {
transformationController: _controller, transformationController: _controller,
minScale: 1, minScale: 1,
maxScale: 6, maxScale: 6,
scaleFactor: 1000000.0,
boundaryMargin: const EdgeInsets.all(160), boundaryMargin: const EdgeInsets.all(160),
panEnabled: _zoomed, panEnabled: _zoomed,
scaleEnabled: true, scaleEnabled: true,
@@ -2221,9 +2290,17 @@ class _ZoomableImageState extends State<_ZoomableImage> {
if (mounted) setState(() => _zoomed = nextZoomed); if (mounted) setState(() => _zoomed = nextZoomed);
_setLocked(nextZoomed || _pointerCount >= 2); _setLocked(nextZoomed || _pointerCount >= 2);
}, },
child: Listener(
onPointerSignal: (event) {
if (event is PointerScrollEvent) {
GestureBinding.instance.pointerSignalResolver
.register(event, (_) {});
}
},
child: child, child: child,
), ),
), ),
),
); );
}, },
), ),
@@ -2637,6 +2714,8 @@ class _VideoControls extends StatefulWidget {
required this.fullscreen, required this.fullscreen,
required this.isLocked, required this.isLocked,
this.isLandscape, this.isLandscape,
required this.isSoftwareDecoding,
required this.onToggleDecoder,
this.onToggleOrientation, this.onToggleOrientation,
required this.onToggleLock, required this.onToggleLock,
required this.onToggleFit, required this.onToggleFit,
@@ -2656,6 +2735,8 @@ class _VideoControls extends StatefulWidget {
final bool fullscreen; final bool fullscreen;
final bool isLocked; final bool isLocked;
final bool? isLandscape; final bool? isLandscape;
final bool isSoftwareDecoding;
final VoidCallback onToggleDecoder;
final VoidCallback? onToggleOrientation; final VoidCallback? onToggleOrientation;
final VoidCallback onToggleLock; final VoidCallback onToggleLock;
final VoidCallback onToggleFit; final VoidCallback onToggleFit;
@@ -2755,6 +2836,17 @@ class _VideoControlsState extends State<_VideoControls> {
onPressed: widget.onToggleLock, onPressed: widget.onToggleLock,
), ),
const Spacer(), const Spacer(),
_RoundControlButton(
tooltip: widget.isSoftwareDecoding
? 'Декодер: S/W (программный). Нажмите для переключения на H/W'
: 'Декодер: H/W (аппаратный). Нажмите для переключения на S/W',
selected: !widget.isSoftwareDecoding,
icon: widget.isSoftwareDecoding
? Icons.memory_rounded
: Icons.speed_rounded,
onPressed: widget.onToggleDecoder,
),
const SizedBox(width: 8),
_SpeedBadgeButton( _SpeedBadgeButton(
currentRate: currentRate, currentRate: currentRate,
onSelected: (newRate) => widget.player.setRate(newRate), onSelected: (newRate) => widget.player.setRate(newRate),
@@ -1,6 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'dart:ui'; import 'dart:ui';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart' hide appBuildNumber; import 'package:flutter/services.dart' hide appBuildNumber;
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
@@ -1439,7 +1440,7 @@ class _SettingsIconBadge extends StatelessWidget {
} }
} }
class _CategoryQuickNav extends StatelessWidget { class _CategoryQuickNav extends StatefulWidget {
const _CategoryQuickNav({ const _CategoryQuickNav({
required this.categories, required this.categories,
required this.onSelect, required this.onSelect,
@@ -1449,20 +1450,55 @@ class _CategoryQuickNav extends StatelessWidget {
categories; categories;
final ValueChanged<GlobalKey> onSelect; final ValueChanged<GlobalKey> onSelect;
@override
State<_CategoryQuickNav> createState() => _CategoryQuickNavState();
}
class _CategoryQuickNavState extends State<_CategoryQuickNav> {
final ScrollController _scrollController = ScrollController();
bool _isHovered = false;
@override
void dispose() {
_scrollController.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final theme = Theme.of(context); final theme = Theme.of(context);
final isDark = theme.brightness == Brightness.dark; final isDark = theme.brightness == Brightness.dark;
return SizedBox( return MouseRegion(
onEnter: (_) => _isHovered = true,
onExit: (_) => _isHovered = false,
child: Listener(
onPointerSignal: (event) {
if (!_isHovered ||
event is! PointerScrollEvent ||
!_scrollController.hasClients) {
return;
}
final delta = event.scrollDelta.dy != 0
? event.scrollDelta.dy
: event.scrollDelta.dx;
if (delta == 0) return;
final target = (_scrollController.offset + delta * 1.5).clamp(
0.0,
_scrollController.position.maxScrollExtent,
);
_scrollController.jumpTo(target);
},
child: SizedBox(
height: 44, height: 44,
child: ListView.separated( child: ListView.separated(
controller: _scrollController,
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: categories.length, itemCount: widget.categories.length,
separatorBuilder: (_, __) => const SizedBox(width: 8), separatorBuilder: (_, __) => const SizedBox(width: 8),
itemBuilder: (context, index) { itemBuilder: (context, index) {
final cat = categories[index]; final cat = widget.categories[index];
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22), borderRadius: BorderRadius.circular(22),
@@ -1482,16 +1518,18 @@ class _CategoryQuickNav extends StatelessWidget {
filter: ImageFilter.blur(sigmaX: 16, sigmaY: 16), filter: ImageFilter.blur(sigmaX: 16, sigmaY: 16),
child: Material( child: Material(
color: isDark color: isDark
? theme.colorScheme.surfaceContainerHigh.withValues(alpha: 0.60) ? theme.colorScheme.surfaceContainerHigh
.withValues(alpha: 0.60)
: Colors.white.withValues(alpha: 0.82), : Colors.white.withValues(alpha: 0.82),
child: InkWell( child: InkWell(
borderRadius: BorderRadius.circular(22), borderRadius: BorderRadius.circular(22),
onTap: () { onTap: () {
HapticFeedback.selectionClick(); HapticFeedback.selectionClick();
onSelect(cat.key); widget.onSelect(cat.key);
}, },
child: Container( child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 7), padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 7),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(22), borderRadius: BorderRadius.circular(22),
border: Border.all( border: Border.all(
@@ -1526,7 +1564,8 @@ class _CategoryQuickNav extends StatelessWidget {
], ],
), ),
child: Center( child: Center(
child: Icon(cat.icon, size: 14, color: Colors.white), child: Icon(cat.icon,
size: 14, color: Colors.white),
), ),
), ),
const SizedBox(width: 8), const SizedBox(width: 8),
@@ -1547,6 +1586,8 @@ class _CategoryQuickNav extends StatelessWidget {
); );
}, },
), ),
),
),
); );
} }
} }
@@ -427,6 +427,8 @@ class _ViewedPostTile extends StatelessWidget {
) )
: CachedNetworkImage( : CachedNetworkImage(
imageUrl: image, imageUrl: image,
memCacheWidth: 320,
memCacheHeight: 320,
fit: BoxFit.cover, fit: BoxFit.cover,
placeholder: (_, __) => Container( placeholder: (_, __) => Container(
color: scheme.surfaceContainerHighest, color: scheme.surfaceContainerHighest,
+5
View File
@@ -1,9 +1,14 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:media_kit/media_kit.dart';
import 'app/app.dart'; import 'app/app.dart';
void main() { void main() {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
MediaKit.ensureInitialized();
// Optimize image cache to prevent memory bloat and OOM crashes
PaintingBinding.instance.imageCache.maximumSizeBytes = 180 * 1024 * 1024; // 180 MB
PaintingBinding.instance.imageCache.maximumSize = 120; // 120 images
runApp(const ProviderScope(child: GelRuleApp())); runApp(const ProviderScope(child: GelRuleApp()));
} }
+1 -1
View File
@@ -580,7 +580,7 @@ class _DesktopShellState extends State<_DesktopShell>
), ),
), ),
child: Text( child: Text(
'v3.6.1', 'v3.6.4',
style: TextStyle( style: TextStyle(
fontSize: 10, fontSize: 10,
fontWeight: fontWeight:
+12 -5
View File
@@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:collection'; import 'dart:collection';
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -232,7 +233,7 @@ class _PostCardState extends ConsumerState<PostCard>
} }
final dpr = MediaQuery.devicePixelRatioOf(context); final dpr = MediaQuery.devicePixelRatioOf(context);
final cacheWidth = final cacheWidth =
(constraints.maxWidth * dpr).round().clamp(320, 1800); (constraints.maxWidth * dpr).round().clamp(280, 960);
final headers = _headersFor(post); final headers = _headersFor(post);
final videoUrls = MediaUrlSelector.video(post); final videoUrls = MediaUrlSelector.video(post);
if (!mobile && if (!mobile &&
@@ -590,7 +591,15 @@ class _FeedVideoPreviewState extends State<_FeedVideoPreview> {
super.initState(); super.initState();
MediaKit.ensureInitialized(); MediaKit.ensureInitialized();
_player = Player(); _player = Player();
_controller = VideoController(_player); final isDesktop =
Platform.isLinux || Platform.isWindows || Platform.isMacOS;
_controller = VideoController(
_player,
configuration: VideoControllerConfiguration(
enableHardwareAcceleration: !isDesktop,
hwdec: isDesktop ? 'no' : 'auto-safe',
),
);
_player.stream.error.listen((_) { _player.stream.error.listen((_) {
if (mounted) setState(() => _failed = true); if (mounted) setState(() => _failed = true);
}); });
@@ -633,17 +642,15 @@ class _FeedVideoPreviewState extends State<_FeedVideoPreview> {
AnimatedOpacity( AnimatedOpacity(
opacity: _ready ? 1 : 0, opacity: _ready ? 1 : 0,
duration: AppMotion.duration(context, 180), duration: AppMotion.duration(context, 180),
child: ColoredBox(
color: Colors.black,
child: Video( child: Video(
controller: _controller, controller: _controller,
fit: BoxFit.cover, fit: BoxFit.cover,
fill: Colors.transparent,
controls: null, controls: null,
pauseUponEnteringBackgroundMode: false, pauseUponEnteringBackgroundMode: false,
resumeUponEnteringForegroundMode: false, resumeUponEnteringForegroundMode: false,
), ),
), ),
),
], ],
); );
} }
+3 -1
View File
@@ -68,7 +68,8 @@ class PostMasonryGrid extends StatelessWidget {
final spacing = mobile ? 8.0 : 12.0; final spacing = mobile ? 8.0 : 12.0;
Widget buildCard(Post post) { Widget buildCard(Post post) {
return PostCard( return RepaintBoundary(
child: PostCard(
post: post, post: post,
blurExplicit: blurExplicit && !nsfwEnabled, blurExplicit: blurExplicit && !nsfwEnabled,
showBadges: showBadges, showBadges: showBadges,
@@ -86,6 +87,7 @@ class PostMasonryGrid extends StatelessWidget {
onToggleSelected == null ? null : () => onToggleSelected!(post), onToggleSelected == null ? null : () => onToggleSelected!(post),
onAddToCollection: onAddToCollection:
onAddToCollection == null ? null : () => onAddToCollection!(post), onAddToCollection == null ? null : () => onAddToCollection!(post),
),
); );
} }
+1 -1
View File
@@ -1,7 +1,7 @@
name: gel_rule_app name: gel_rule_app
description: Local backend/core layer for a Flutter booru browser app. description: Local backend/core layer for a Flutter booru browser app.
publish_to: "none" publish_to: "none"
version: 3.6.1+83 version: 3.6.4+86
environment: environment:
sdk: ">=3.3.0 <4.0.0" sdk: ">=3.3.0 <4.0.0"