Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of memory #1684

Closed
1 of 2 tasks
NiallBunting opened this issue Jan 15, 2024 · 4 comments
Closed
1 of 2 tasks

Out of memory #1684

NiallBunting opened this issue Jan 15, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@NiallBunting
Copy link

NiallBunting commented Jan 15, 2024

Checklist

  • I could not find a solution in the documentation, the existing issues or discussions.
  • I already asked for help in the chat

In which Project did the bug appear?

Other

If you selected "Other" as Project, please enter in which project the bug occurred.

Personal

On which platform did the bug appear?

Android

SDK Version

0.25.5

Describe the problem caused by this bug

Logged in and after a successful connection I get the following error and matrix fails to load any chats.

Steps To Reproduce

No response

Screenshots or Logs

I/flutter (11715): LoginState.loggedIn
W/1.ui (11715): type=1400 audit(0.0:8210): avc: granted { execmem } for scontext=u:r:untrusted_app:s0:c171,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c171,c256,c512,c768 tclass=process app=uk.co.app
E/flutter (11715): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Out of Memory
E/flutter (11715): #0 new Uint8List (dart:typed_data-patch/typed_data_patch.dart:2237:3)
E/flutter (11715): #1 BufferedFileReader.loadBytes (package:hive/src/io/buffered_file_reader.dart:73:18)
E/flutter (11715): #2 _KeyReader._load (package:hive/src/io/frame_io_helper.dart:89:40)
E/flutter (11715): #3 _KeyReader.readKeys (package:hive/src/io/frame_io_helper.dart:69:31)
E/flutter (11715): #4 _rootRunUnary (dart:async/zone.dart:1407:47)
E/flutter (11715): #5 _CustomZone.runUnary (dart:async/zone.dart:1308:19)
E/flutter (11715): #6 _FutureListener.handleValue (dart:async/future_impl.dart:162:18)
E/flutter (11715): #7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:846:45)
E/flutter (11715): #8 Future._propagateToListeners (dart:async/future_impl.dart:875:13)
E/flutter (11715): #9 Future._completeWithValue (dart:async/future_impl.dart:647:5)
E/flutter (11715): #10 _rootRunUnary (dart:async/zone.dart:1407:47)
E/flutter (11715): #11 _CustomZone.runUnary (dart:async/zone.dart:1308:19)
E/flutter (11715): #12 _FutureListener.handleValue (dart:async/future_impl.dart:162:18)
E/flutter (11715): #13 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:846:45)
E/flutter (11715): #14 Future._propagateToListeners (dart:async/future_impl.dart:875:13)
E/flutter (11715): #15 Future._completeWithValue (dart:async/future_impl.dart:647:5)
E/flutter (11715): #16 _rootRunUnary (dart:async/zone.dart:1407:47)
E/flutter (11715): #17 _CustomZone.runUnary (dart:async/zone.dart:1308:19)
E/flutter (11715): #18 _FutureListener.handleValue (dart:async/future_impl.dart:162:18)
E/flutter (11715): #19 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:846:45)
E/flutter (11715): #20 Future._propagateToListeners (dart:async/future_impl.dart:875:13)
E/flutter (11715): #21 Future._completeWithValue (dart:async/future_impl.dart:647:5)
E/flutter (11715): #22 Future._asyncCompleteWithValue. (dart:async/future_impl.dart:721:7)
E/flutter (11715): #23 _rootRun (dart:async/zone.dart:1399:13)
E/flutter (11715): #24 _CustomZone.run (dart:async/zone.dart:1301:19)
E/flutter (11715): #25 _CustomZone.bindCallback. (dart:async/zone.dart:1233:23)
E/flutter (11715): #26 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (11715): #27 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
E/flutter (11715):
I/flutter (11715): [Matrix] Error during processing events - Out of Memory
I/flutter (11715): #0 new Uint8List (dart:typed_data-patch/typed_data_patch.dart:2237:3)
I/flutter (11715): #1 BufferedFileReader.loadBytes (package:hive/src/io/buffered_file_reader.dart:73:18)
I/flutter (11715): #2 _KeyReader._load (package:hive/src/io/frame_io_helper.dart:89:40)
I/flutter (11715): #3 _KeyReader.readKeys (package:hive/src/io/frame_io_helper.dart:69:31)
I/flutter (11715): #4 _rootRunUnary (dart:async/zone.dart:1407:47)
I/flutter (11715): #5 _CustomZone.runUnary (dart:async/zone.dart:1308:19)
I/flutter (11715): #6 _FutureListener.handleValue (dart:async/future_impl.dart:162:18)
I/flutter (11715): #7 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:846:45)
I/flutter (11715): #8 Future._propagateToListeners (dart:async/future_impl.dart:875:13)
I/flutter (11715): #9 Future._completeWithValue (dart:async/future_impl.dart:647:5)
I/flutter (11715): #10 _rootRunUnary (dart:async/zone.dart:1407:47)
I/flutter (11715): #11 _CustomZone.runUnary (dart:async/zone.dart:1308:19)
I/flutter (11715): #12 _FutureListener.handleValue (dart:async/future_impl.dart:162:18)
I/flutter (11715): #13 Future._propagateToListener

Security related

No response

@NiallBunting NiallBunting added the bug Something isn't working label Jan 15, 2024
@krille-chan
Copy link
Contributor

Please add a minimal code sample and steps to reproduce this also some information on what kind of accounts this appears (or on all?) would be helpful

@NiallBunting
Copy link
Author

  Future<String> startSync(String suggestedDeviceId) async {
    _matrixClient = Client('Client',
      databaseBuilder: (_) async {
      final dir = await getApplicationSupportDirectory(); // Recommend path_provider package
      final db = HiveCollectionsDatabase('clientdatabase', dir.path);
      await db.open();
      return db;
    });

    _matrixClient.onSyncStatus.stream.listen((SyncStatusUpdate event) {
      if(event.status == SyncStatus.error) {
        tokenProvider.manager.refreshToken();
        print("SYNC ERORROR!!!");
      }

      if(event.error != null) {
        print(event.error.toString());
        print("SYNC ERROR !!!!");
      }
    });

    _matrixClient.onLoginStateChanged.stream.listen((LoginState e) {
      print(e.toString());

      if(e == LoginState.loggedOut) {
        print("REFESHING TOKEN");
        tokenProvider.manager.refreshToken();
      }
    });

    _matrixClient.onEvent.stream.listen((EventUpdate eventUpdate){
      notifyListeners();
    });

    _matrixClient.onRoomState.stream.listen((Event event) {
      _matrixClient.rooms.forEach((room) {
        if(!_timelines.containsKey(room.id)) {
          _timelines[room.id] = null;
          room.getTimeline(onUpdate: () {
            notifyListeners();
          }).then((timeline) => {
            _timelines[room.id] = timeline
          });
        }
      });

      notifyListeners();
    });


    if(_matrixClient.deviceID != null) {
      _deviceId = _matrixClient.deviceID!;
    } else {
      _deviceId = suggestedDeviceId;
    }
    
    return _deviceId;
  }

  Future<bool> login(OidcUser user) async {
    var userId = "@${user.userInfo['preferred_username']}:${ApiConstants.matrixDomain}";

    if(_matrixClient.isLogged()) {
      _matrixClient.accessToken = user.token.accessToken;
    } else {
      await _matrixClient.init(newHomeserver: Uri.parse(ApiConstants.matrixSever), newToken: user.token.accessToken, newUserID: userId, newDeviceID: _deviceId, newDeviceName: 'Device: ${_deviceId.substring(0, 10)}');

      _matrixClient.postPusher(
          Pusher(
              appId: ApiConstants.appId + (Platform.isAndroid ? ".android" : Platform.isIOS ? '.ios' : '.other'),
              pushkey: _deviceId,
              appDisplayName: ApiConstants.appName,
              data: PusherData(
                  format: 'event_id_only',
                  url: Uri.parse(ApiConstants.matrixPushGateway)
              ),
              deviceDisplayName: 'Device: ${_deviceId.substring(0, 10)}',
              kind: 'http',
              lang: 'en'
          )
      );
    }

This is my rough code. I'm using access tokens and msc3861 on the homesever so not sure if it's related to that or not.

@PhantomRay
Copy link
Contributor

Related to #1601

@krille-chan
Copy link
Contributor

Closed in favor of #1856

@krille-chan krille-chan closed this as not planned Won't fix, can't repro, duplicate, stale Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants