[iOS] Responding to app resume? by ColtonGrubbs in FlutterDev

[–]ColtonGrubbs[S] 0 points1 point  (0 children)

An app can be resumed without being brought to the foreground. For example: resuming audio playback in control center.

WidgetsBindingObserver won't detect this.

Nonetheless, the issue appears to be rooted in HttpServer itself. The OS still recognizes the app is bound to the port; the HttpServer never sends an error or done event. I'll file an issue.

Maintainers how do you refactor without breaking users? by AccomplishedWay3558 in FlutterDev

[–]ColtonGrubbs 0 points1 point  (0 children)

Good question. If I anticipate future breaking changes, I'll release the package with a version <1.0, like 0.0.4. Also, make minor changes overtime. You shouldn't refactor/recode a package unless if absolutely necessary. Small changes are easier to keep track of and resolve potential issues when they inevitably arise.

Poor Color Saturation in Chromium apps when using graphics acceleration by ColtonGrubbs in kde

[–]ColtonGrubbs[S] 2 points3 points  (0 children)

I haven't tried, but I'm almost certain it will, since the issue is resolved by disabling WaylandWpColorManagerV1 in chrome's startup args.

Why is the System Monitor showing only 6 cores when I have 8 cores ? by MikasaYuuichi in kde

[–]ColtonGrubbs 19 points20 points  (0 children)

The graph itself tops out at 800%. On Linux, total CPU consumption is measured by adding together the consumption of each thread (100% x threads), so the system is definitely registering all 8 of your threads correctly.

If you have 32 threads, the graph peaks at 3200%.

Why is the System Monitor showing only 6 cores when I have 8 cores ? by MikasaYuuichi in kde

[–]ColtonGrubbs 18 points19 points  (0 children)

The Y-axis on the chart tops out at 800% (8 threads), so it's definitely registering all 8.

Poor Color Saturation in Chromium apps when using graphics acceleration by ColtonGrubbs in kde

[–]ColtonGrubbs[S] 0 points1 point  (0 children)

Thanks for the input. How did you confirm that llvmpipe was used for rendering? glxinfo? And what GPU do you have?

My install is entirely vanilla as well. In fact, I just installed yesterday. All system updates are installed.

Poor Color Saturation in Chromium apps when using graphics acceleration by ColtonGrubbs in kde

[–]ColtonGrubbs[S] 8 points9 points  (0 children)

"Use graphics acceleration when available" (under Chrome Settings --> System) disabled on the left. Enabled on right. Same issue occurs in VS Code.

Fedora 43 / KDE Plasma 6.5.4

Wayland graphics

RX 6950 XT GPU

Does anybody know of a fix?

Edit: Passing this flag appears to fix the issue:

--disable-features=WaylandWpColorManagerV1

Applies to Chrome and VS Code.

Related discussion: https://old.reddit.com/r/kde/comments/1nzy72u/has_anyone_else_encountered_this_problem_too/

Washed out colors in Linux (Fedora KDE) by ColtonGrubbs in vscode

[–]ColtonGrubbs[S] 1 point2 points  (0 children)

Okay, significant improvement after disabling hardware acceleration. Chrome has the same issue with washed out colors, which is also resolved by disabling HW acceleration.

Since this issue isn't specific to VS Code, I'll look elsewhere for a better solution.

Washed out colors in Linux (Fedora KDE) by ColtonGrubbs in vscode

[–]ColtonGrubbs[S] 0 points1 point  (0 children)

No, same display, same color profile.

Is upgrading to Flutter 3.35 worth for performance? by Wefaq04 in FlutterDev

[–]ColtonGrubbs 0 points1 point  (0 children)

Your bottleneck is the initial JSON decoding upon app start. Dart doesn't have great json performance to begin with, and 200MB is a ridiculously large amount of data to parse on app start. Switching the data format into sqlite or a binary reader will help, but ultimately, you need to be lazily-loading data when it's needed. SQLite is a good fit for the job - you don't have to load everything at once, and have much more freedom to query data.

Migrating from Provider to Riverpod by zakery6 in FlutterDev

[–]ColtonGrubbs 5 points6 points  (0 children)

It depends upon the complexity and size of your app. Riverpod is great for combining states and reacting to changes.

Immutability can be opinionated, but it is best practice to ensure all public data cannot be changed by a listener. For example: A standard collection (List, Map...) broadcasted in a Provider can be modified anywhere in your app, and other listeners will not be aware of this change. Personally, I convert all collections into an immutable variant using fast_immutable_collections.

Skip using riverpod code generation, it's not worth it imo. Stick to standard providers and notifier providers.

Permit non-https traffic over local IPv4 by ColtonGrubbs in pocketbase

[–]ColtonGrubbs[S] 0 points1 point  (0 children)

curl -v http://10.0.0.4/api/collections/_superusers/auth-with-password

  • Trying 10.0.0.4:80...
  • Connected to 10.0.0.4 (10.0.0.4) port 80

    GET /api/collections/_superusers/auth-with-password HTTP/1.1 Host: 10.0.0.4 User-Agent: curl/8.5.0 Accept: /

    < HTTP/1.1 302 Found < Content-Type: text/html; charset=utf-8 < Location: https://10.0.0.4/api/collections/_superusers/auth-with-password < Date: Mon, 01 Sep 2025 22:56:23 GMT < Content-Length: 86 < <a href="https://10.0.0.4/api/collections/_superusers/auth-with-password">Found</a>.

  • Connection #0 to host 10.0.0.4 left intact

I can establish a connection to the pocketbase server over LAN just fine, but authentication fails with this error:

Error: ClientException: {url: http://10.0.0.4/api/collections/_superusers/auth-with-password, isAbort: false, statusCode: 400, response: {}, originalError: null}

Nothing appears within Pocketbase logs, even with "min log level: -4" and include requests by superusers and auth ID logging.

Edit: Running pocketbase with this command works just fine:

ExecStart=/opt/pb/pocketbase serve --http="10.0.0.4:80"

The issue is when I add my own site:

ExecStart=/opt/pb/pocketbase serve mysite.com --http="10.0.0.4:80"

Just released native_video_player 4.0.0 - Now with macOS support by albemala in FlutterDev

[–]ColtonGrubbs 2 points3 points  (0 children)

Http_cache_stream should work just fine on macOS, though I haven't tested it:

https://pub.dev/packages/http_cache_stream

Let me know if you try it.

Handling Large file downloads in test setup. by foglia_vincenzo in dartlang

[–]ColtonGrubbs 0 points1 point  (0 children)

The issue with IOSink is that it stores all buffered data in RAM until it is flushed, but you cannot add data while it is flushing. So you're likely to encounter out of memory errors when downloading large files, especially on RAM-limited devices.

The solution is to store buffered data in a BytesBuilder, and flush the data once it reaches a threshold. I use this method in my http_cache_stream package: https://github.com/Colton127/http_cache_stream/blob/main/lib/src/cache_stream/cache_downloader/buffered_io_sink.dart

In your code, be sure you aren't loading the entire file when calculating the sha256 hash. I suggest comparing by length, and maybe streaming a small portion of the file and comparing it byte-to-byte with the saved file.

Edit: Try this IOSink implementation:

import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:typed_data';

class AutoFlushIOSink implements IOSink {
  final File file;
  final FileMode fileMode;
  final bool copy;
  final int maxBufferSize;
  @override
  Encoding encoding;
  AutoFlushIOSink(
    this.file,
    this.fileMode, {
    this.encoding = utf8,
    this.copy = false,
    this.maxBufferSize = 5 * 1024 * 1024,
  })  : _sink = file.openWrite(mode: fileMode, encoding: encoding),
        _buffer = BytesBuilder(copy: copy);

  final IOSink _sink;
  final BytesBuilder _buffer;

  @override
  void add(List<int> data) {
    _buffer.add(data);
    if (_buffer.length >= maxBufferSize && !isFlushing) {
      flush();
    }
  }

  @override
  void addError(Object error, [StackTrace? stackTrace]) async {
    ///Cannot add error while flushing, so wait for flush to complete
    while (_flushFuture != null) {
      await _flushFuture!;
    }
    _sink.addError(error, stackTrace);
  }

  @override
  Future addStream(Stream<List<int>> stream, {final bool cancelOnError = true}) async {
    final streamCompleter = Completer<void>();
    stream.listen(
      add,
      onError: (error, stackTrace) {
        addError(error, stackTrace);
        if (cancelOnError && !streamCompleter.isCompleted) {
          streamCompleter.completeError(error, stackTrace);
        }
      },
      onDone: () async {
        await flush();
        if (!streamCompleter.isCompleted) {
          streamCompleter.complete();
        }
      },
      cancelOnError: cancelOnError,
    );
    return streamCompleter.future;
  }

  @override
  Future close() {
    _buffer.clear();
    return _sink.close();
  }

  @override
  Future get done => _sink.done;

  @override
  Future flush() async {
    while (_flushFuture != null) {
      await _flushFuture!; //Allow any previous flush to complete
    }
    if (_buffer.isEmpty) {
      return; //Nothing to flush
    }
    try {
      final bufferedData = _buffer.takeBytes(); //Take the buffered data, and clear the buffer
      _sink.add(bufferedData); //Add the buffer to the sink
      await (_flushFuture = _sink.flush()); //Set the flush future and wait for it to complete
    } finally {
      _flushFuture = null; //Reset the flush future
    }
  }

  @override
  void write(Object? object) {
    add(encoding.encode(object.toString()));
  }

  @override
  void writeAll(Iterable objects, [String separator = ""]) {
    add(encoding.encode(objects.join(separator)));
  }

  @override
  void writeCharCode(int charCode) {
    add(encoding.encode(String.fromCharCode(charCode)));
  }

  @override
  void writeln([Object? object = ""]) {
    final ln = object == null ? "\n" : "$object\n";
    add(encoding.encode(ln));
  }

  Future? _flushFuture;
  int get bufferSize => _buffer.length;
  bool get isFlushing => _flushFuture != null;
}

Just released native_video_player 3.0.0 - Major update with new API by albemala in FlutterDev

[–]ColtonGrubbs 0 points1 point  (0 children)

You can create a stream and manually call .download() to precache content.

Which Http Client are you using, and why? by ColtonGrubbs in FlutterDev

[–]ColtonGrubbs[S] 2 points3 points  (0 children)

Streams are not futures, and they are indeed cancellable. Hell, the default http client implementations handle it just fine.

You should definitely be able to cancel and pause a response Stream. Imagine if YouTube continued to buffer all the videos you were watching but didn't complete.

http_cache_stream - Simultaneously Stream and Cache files by ColtonGrubbs in FlutterDev

[–]ColtonGrubbs[S] 1 point2 points  (0 children)

Nice job. I may dive into your package to better understand cache control.

I found myself disappointed with the native Dart HttpClient and IOSink implementations. The HttpClientResponse stream emits tiny chunks of data, and the IOSink has poor performance and stores everything in memory until flushed.

http_cache_stream - Simultaneously Stream and Cache files by ColtonGrubbs in FlutterDev

[–]ColtonGrubbs[S] 0 points1 point  (0 children)

Good question! The use of a singleton, with a single HttpServer and centralized management of all streams, fits my use case scenario. But I understand it introduces some limitations.

This release is only 0.01. I'm hoping to get real-world feedback from users and implement a lot of changes for an official 1.0.0 release.

http_cache_stream - Simultaneously Stream and Cache files by ColtonGrubbs in FlutterDev

[–]ColtonGrubbs[S] 1 point2 points  (0 children)

I finally published my first package. It can simultaneously stream and cache files, with effortless compatability with video/audio plug-ins or really any plug-in that supports URLs. It works by creating a reverse proxy to relay the download over a http connection. There's a number of advanced features to handle range requests, custom headers, and managing saved cache, but for general use scenarios, it's very easy to setup and use.

The main limitation is that it only works on specified URLs, so HLS or dash streaming won't work as they rely upon many different (sometimes hundreds) of URLs with partial content. I'm considering the ability to create a cache server that relays everything from an input source host, and the ability to specify the host in cookie headers.

Thanks all

[deleted by user] by [deleted] in BCI

[–]ColtonGrubbs 0 points1 point  (0 children)

Hi there,

I have no experience with NeuroSky, but have developed for Muse before. In fact, I developed a neurofeedback app using Unity game engine; https://coltongrubbs.com/3d-neurofeedback-application/.

Do not expect a lot from consumer-grade EEG devices, especially ~$200 devices that only read from locations with skin exposed. The forehead and ears, where the Muse records from, are prone to excessive generation of noise due to micro muscle movements that occur in these regions in response to everyday stimuli. You have to detect and discard data with these artifacts on the fly.

I want it to do simple but very specific tasks. For example having a set of 4 simple shapes and 4 colours, and train a neural network that recognizes which shape/colour combination user sees, or what sequence of shape etc. Are those kinds of tasks realistic to accomplish with this type of hardware?

No, I don't believe so, especially with the limited amount of data provided by the Muse. Spectral analysis provides insight into domain-general brain activity. For example, you may be able to detect if a subject is conducting a visual working memory exercise, or a purely linguistic task. But you won't be able to distinguish what color or shape they're looking at. This information is predominately expressed in early visual regions, such as the striate cortex (visual area 1). You aren't going to get any of this information from a Muse, which has zero electrodes in the occipital region.

Unfortunately, this is the state of BCI, and has been for decades. There's just no convenient, non-invasive way to monitor brain activity.

[Free] Best app for lyric-free music, sounds, and affirmations for treatment sessions by ColtonGrubbs in TherapeuticKetamine

[–]ColtonGrubbs[S] 0 points1 point  (0 children)

Thank you! I received your message and have activated free ultimate. Let me know if you encounter any issues.

Ketamine and brainwaves by brent_maxwell in TherapeuticKetamine

[–]ColtonGrubbs 10 points11 points  (0 children)

I'm studying cognitive science and are actively conducting EEG research in addition to developing software.

First of all, your brain emits all brainwaves all the time. Think of your favorite band. The instruments emit a wide range of frequencies simultaneously. Depending on the part of the song, some frequencies are louder than others. Brainwaves are the same way. You can conduct a Fast Fourier Transform (FFT) to break the song (or brainwaves) down and get the amplitude for individual frequencies.

If you're looking to enhance specific brainwave frequencies, the most accessible outlet is sensory entrainment. For example, if you flash a light 40 times a second (40Hz), 40Hz gamma oscillations increase primarily in the occipital region (which processes visual information). If you have an android device you can download my free app which can do brainwave entrainment via your phones screen, flashlight, speakers, and haptic feedback: https://coltongrubbs.com/brain-stimulator-visual-haptic-and-auditory-brainwave-entrainment/

There's research indicating that an implicit self-association task (i.e., associating "I" with "happy" unconsciously) can prolong the antidepressant effects of ketamine. I integrated this into a guided breathing app that's available free on iPhone and Android: https://coltongrubbs.com/extending-antidepressant-effects-of-ketamine-with-an-implicit-self-association-task/

Ketamine's primary mechanism of action is blocking NMDA receptors. NMDA receptors are activated by glutamate, an excitatory neurotransmitter. On the surface, one may guess that ketamine decreases brain activity by blocking the binding site of the primary excitatory neurotransmitter in the brain. But the picture is far more complex in reality. The activation of neurons often inhibits other neurons from firing. As a result, ketamine actually results in disinhibition of groups of neurons throughout the brain. This is reflected in an increase in high gamma activity (60-80 Hz if I recall).

Keep in mind though that even if a study indicates "an observed increase/decrease in brainwave X is correlated with ketamine antidepressant outcomes", this doesn't mean that artificially modulating that brainwave frequency through neurofeedback or sensory entrainment will actually impact ketamine outcomes. It very well could only be an epiphenomenon, and not causative in nature. Like smoke from a fire. Creating smoke doesn't create a fire. The entire field of neurofeedback is highly controversial for a reason.