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

Android redraw requests aren't implemented #1723

Closed
glalonde opened this issue Sep 23, 2020 · 4 comments · Fixed by #1953
Closed

Android redraw requests aren't implemented #1723

glalonde opened this issue Sep 23, 2020 · 4 comments · Fixed by #1953
Labels
DS - android H - good first issue Ideal for new contributors H - help wanted Someone please save us S - platform parity Unintended platform differences

Comments

@glalonde
Copy link

pub fn request_redraw(&self) {

For now, implementing redraw in MainEventsCleared works. But I'm not sure what's supposed to go on here.

@francesca64 francesca64 added H - good first issue Ideal for new contributors DS - android H - help wanted Someone please save us S - platform parity Unintended platform differences labels Sep 24, 2020
@francesca64
Copy link
Member

francesca64 commented Sep 24, 2020

Thanks for reporting this! It looks like it was just punted:

pub fn request_redraw(&self) {
// TODO
}

I haven't seen any discussion indicating that it'd be thorny to implement; it's fairly simple on most platforms, albeit very platform-specific. A PR would be very welcome!

@francesca64
Copy link
Member

@dvc94ch do you remember anything about this?

@dvc94ch
Copy link
Member

dvc94ch commented Sep 25, 2020

Not sure what it's useful for. I guess setting an AtomicBool and calling looper.wake() should do the trick?

@rmyhovych
Copy link

rmyhovych commented Nov 14, 2020

@francesca64 I've been having an issue with this in my Android application, where the RedrawRequested event was never called and my scene would stay static after 2 frames, so I made my own small function that fixed it for me:

    pub fn request_redraw() {
        match ndk_glue::native_window().as_ref() {
            Some(native_window) => {
                let a_native_window: *mut ndk_sys::ANativeWindow = native_window.ptr().as_ptr();
                let a_native_activity: *mut ndk_sys::ANativeActivity =
                    ndk_glue::native_activity().ptr().as_ptr();
                unsafe {
                    match (*(*a_native_activity).callbacks).onNativeWindowRedrawNeeded {
                        Some(callback) => callback(a_native_activity, a_native_window),
                        None => (),
                    };
                };
            }
            None => (),
        }
    }

I'm very new to Rust and Native Android development, is there anything wrong with my way of doing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DS - android H - good first issue Ideal for new contributors H - help wanted Someone please save us S - platform parity Unintended platform differences
4 participants