Code Monkey home page Code Monkey logo

bevy-in-app's Introduction

Bevy in App

Integrate the Bevy engine into existing iOS | Android apps.

If you want to add a mini-game to an existing app, or implement some dynamic UI components, charts ..., or just want to take advantage of the Motion Sensors on your phone for some cool gameplay, you can't use WinitPlugin. Because winit will take over the entire app initialization process and windowing, but we need to create bevy::App in an existing app instance, and we may also want bevy::App to run in an iOS UIView or Android SurfaceView of any size.

This repository implements such a scenario and uses the phone's motion sensor to play breakout mini-games.

Screenshot

Bevy in iOS App Bevy in Android App

iOS

# Add iOS target
rustup target add aarch64-apple-ios

# Build for iOS target
sh ./ios_build.sh --release

Then, Open iOS/bevy_in_iOS.xcodeproj with Xcode,connect an iOS device and run.

Android

Set up Android environment

Assuming your computer already has Android Studio installed, go to Android Studio > Tools > SDK Manager > Android SDK > SDK Tools. Check the following options for installation and click OK.

  • Android SDK Build-Tools
  • Android SDK Command-line Tools
  • NDK(Side by side)

Then, set two following environment variables:

export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
# Replace the NDK version number with the version you installed
export NDK_HOME=$ANDROID_SDK_ROOT/ndk/23.1.7779620

Add build targets

# Since simulator and virtual devices only support GLES,
# `x86_64-linux-android` and `i686-linux-android` targets are not necessary
rustup target add aarch64-linux-android

Build

# Install cargo-so subcommand
cargo install cargo-so

# Build
sh ./android_build.sh --release

bevy-in-app's People

Contributors

aprchen avatar jinleili avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bevy-in-app's Issues

This is great work!

You've put a ton of effort into this repo and it looks really great. Many thanks for making it public!

Running multiple instances in different activities

Hi there! Thankyou for making such an amazing interface for integrating bevy inside an Android/iOS app.

I was trying to run two different games in different Activities and wanted to switch between them on click of an button.
The first game runs fine however while switching to another activity I get some error related to init_ndk_context method.

I have confirmed that both the generated .so files of the games are valid and they do run when added individually.

Link to repo: https://github.com/souvikinator/bevy-rapier-determinism-test-/tree/f/mobile_template

here are the error logs:

2024-04-19 04:54:50.528  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created texture Valid((10, 1, Vulkan)) with TextureDescriptor { label: None, size: Extent3d { width: 1, height: 1, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: D2, format: Rgba8UnormSrgb, usage: TextureUsages(COPY_DST | TEXTURE_BINDING), view_formats: [] }
2024-04-19 04:54:50.529  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created texture Valid((11, 1, Vulkan)) with TextureDescriptor { label: None, size: Extent3d { width: 1, height: 1, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: D3, format: Rgba8Unorm, usage: TextureUsages(COPY_DST | TEXTURE_BINDING), view_formats: [] }
2024-04-19 04:54:50.530  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created buffer Valid((0, 1, Vulkan)) with BufferDescriptor { label: Some("Mesh Vertex Buffer"), size: 2048, usage: BufferUsages(VERTEX), mapped_at_creation: true }
2024-04-19 04:54:50.531  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created buffer Valid((1, 1, Vulkan)) with BufferDescriptor { label: Some("Mesh Index Buffer"), size: 744, usage: BufferUsages(INDEX), mapped_at_creation: true }
2024-04-19 04:54:50.532  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created buffer Valid((2, 1, Vulkan)) with BufferDescriptor { label: None, size: 32, usage: BufferUsages(COPY_DST | UNIFORM), mapped_at_creation: true }
2024-04-19 04:54:50.533  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created buffer Valid((3, 1, Vulkan)) with BufferDescriptor { label: None, size: 32, usage: BufferUsages(COPY_DST | UNIFORM), mapped_at_creation: true }
2024-04-19 04:54:50.534  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created buffer Valid((4, 1, Vulkan)) with BufferDescriptor { label: None, size: 1536, usage: BufferUsages(COPY_DST | UNIFORM), mapped_at_creation: false }
2024-04-19 04:54:50.535  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created buffer Valid((5, 1, Vulkan)) with BufferDescriptor { label: None, size: 12, usage: BufferUsages(COPY_DST | UNIFORM), mapped_at_creation: true }
2024-04-19 04:54:50.536  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created buffer Valid((6, 1, Vulkan)) with BufferDescriptor { label: None, size: 96, usage: BufferUsages(COPY_DST | STORAGE), mapped_at_creation: true }
2024-04-19 04:54:50.538  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created buffer Valid((7, 1, Vulkan)) with BufferDescriptor { label: None, size: 1360, usage: BufferUsages(COPY_DST | VERTEX), mapped_at_creation: false }
2024-04-19 04:54:50.539  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created buffer Valid((8, 1, Vulkan)) with BufferDescriptor { label: None, size: 24, usage: BufferUsages(COPY_DST | INDEX), mapped_at_creation: false }
2024-04-19 04:54:50.583  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created render pipeline Valid((0, 1, Vulkan)) with RenderPipelineDescriptor { label: Some("sprite_pipeline"), layout: Some((0, 1, Vulkan)), vertex: VertexState { stage: ProgrammableStageDescriptor { module: (0, 1, Vulkan), entry_point: "vertex" }, buffers: [VertexBufferLayout { array_stride: 80, step_mode: Instance, attributes: [VertexAttribute { format: Float32x4, offset: 0, shader_location: 0 }, VertexAttribute { format: Float32x4, offset: 16, shader_location: 1 }, VertexAttribute { format: Float32x4, offset: 32, shader_location: 2 }, VertexAttribute { format: Float32x4, offset: 48, shader_location: 3 }, VertexAttribute { format: Float32x4, offset: 64, shader_location: 4 }] }] }, primitive: PrimitiveState { topology: TriangleList, strip_index_format: None, front_face: Ccw, cull_mode: None, unclipped_depth: false, polygon_mode: Fill, conservative: false }, depth_stencil: None, multisample: MultisampleState { count: 4, mask: 18446744073709551615, alpha_to_coverage_enabled: false }, fragment: Some(FragmentState { stage: ProgrammableStageDescriptor { module: (0, 1, Vulkan), entry_point: "fragment" }, targets: [Some(ColorTargetState { format: Rgba8UnormSrgb, blend: Some(BlendState { color: BlendComponent { src_factor: SrcAlpha, dst_factor: OneMinusSrcAlpha, operation: Add }, alpha: BlendComponent { src_factor: One, dst_factor: OneMinusSrcAlpha, operation: Add } }), write_mask: ColorWrites(RED | GREEN | BLUE | ALPHA) })] }), multiview: None }
2024-04-19 04:54:50.594  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created render pipeline Valid((1, 1, Vulkan)) with RenderPipelineDescriptor { label: Some("sprite_pipeline"), layout: Some((0, 1, Vulkan)), vertex: VertexState { stage: ProgrammableStageDescriptor { module: (0, 1, Vulkan), entry_point: "vertex" }, buffers: [VertexBufferLayout { array_stride: 80, step_mode: Instance, attributes: [VertexAttribute { format: Float32x4, offset: 0, shader_location: 0 }, VertexAttribute { format: Float32x4, offset: 16, shader_location: 1 }, VertexAttribute { format: Float32x4, offset: 32, shader_location: 2 }, VertexAttribute { format: Float32x4, offset: 48, shader_location: 3 }, VertexAttribute { format: Float32x4, offset: 64, shader_location: 4 }] }] }, primitive: PrimitiveState { topology: TriangleList, strip_index_format: None, front_face: Ccw, cull_mode: None, unclipped_depth: false, polygon_mode: Fill, conservative: false }, depth_stencil: None, multisample: MultisampleState { count: 4, mask: 18446744073709551615, alpha_to_coverage_enabled: false }, fragment: Some(FragmentState { stage: ProgrammableStageDescriptor { module: (0, 1, Vulkan), entry_point: "fragment" }, targets: [Some(ColorTargetState { format: Rgba8UnormSrgb, blend: Some(BlendState { color: BlendComponent { src_factor: SrcAlpha, dst_factor: OneMinusSrcAlpha, operation: Add }, alpha: BlendComponent { src_factor: One, dst_factor: OneMinusSrcAlpha, operation: Add } }), write_mask: ColorWrites(RED | GREEN | BLUE | ALPHA) })] }), multiview: None }
2024-04-19 04:54:50.623  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created render pipeline Valid((2, 1, Vulkan)) with RenderPipelineDescriptor { label: Some("transparent_mesh2d_pipeline"), layout: Some((1, 1, Vulkan)), vertex: VertexState { stage: ProgrammableStageDescriptor { module: (1, 1, Vulkan), entry_point: "vertex" }, buffers: [VertexBufferLayout { array_stride: 32, step_mode: Vertex, attributes: [VertexAttribute { format: Float32x3, offset: 0, shader_location: 0 }, VertexAttribute { format: Float32x3, offset: 12, shader_location: 1 }, VertexAttribute { format: Float32x2, offset: 24, shader_location: 2 }] }] }, primitive: PrimitiveState { topology: TriangleList, strip_index_format: None, front_face: Ccw, cull_mode: None, unclipped_depth: false, polygon_mode: Fill, conservative: false }, depth_stencil: None, multisample: MultisampleState { count: 4, mask: 18446744073709551615, alpha_to_coverage_enabled: false }, fragment: Some(FragmentState { stage: ProgrammableStageDescriptor { module: (2, 1, Vulkan), entry_point: "fragment" }, targets: [Some(ColorTargetState { format: Rgba8UnormSrgb, blend: Some(BlendState { color: BlendComponent { src_factor: SrcAlpha, dst_factor: OneMinusSrcAlpha, operation: Add }, alpha: BlendComponent { src_factor: One, dst_factor: OneMinusSrcAlpha, operation: Add } }), write_mask: ColorWrites(RED | GREEN | BLUE | ALPHA) })] }), multiview: None }
2024-04-19 04:54:50.631  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created render pipeline Valid((3, 1, Vulkan)) with RenderPipelineDescriptor { label: Some("ui_pipeline"), layout: Some((2, 1, Vulkan)), vertex: VertexState { stage: ProgrammableStageDescriptor { module: (3, 1, Vulkan), entry_point: "vertex" }, buffers: [VertexBufferLayout { array_stride: 40, step_mode: Vertex, attributes: [VertexAttribute { format: Float32x3, offset: 0, shader_location: 0 }, VertexAttribute { format: Float32x2, offset: 12, shader_location: 1 }, VertexAttribute { format: Float32x4, offset: 20, shader_location: 2 }, VertexAttribute { format: Uint32, offset: 36, shader_location: 3 }] }] }, primitive: PrimitiveState { topology: TriangleList, strip_index_format: None, front_face: Ccw, cull_mode: None, unclipped_depth: false, polygon_mode: Fill, conservative: false }, depth_stencil: None, multisample: MultisampleState { count: 1, mask: 18446744073709551615, alpha_to_coverage_enabled: false }, fragment: Some(FragmentState { stage: ProgrammableStageDescriptor { module: (3, 1, Vulkan), entry_point: "fragment" }, targets: [Some(ColorTargetState { format: Rgba8UnormSrgb, blend: Some(BlendState { color: BlendComponent { src_factor: SrcAlpha, dst_factor: OneMinusSrcAlpha, operation: Add }, alpha: BlendComponent { src_factor: One, dst_factor: OneMinusSrcAlpha, operation: Add } }), write_mask: ColorWrites(RED | GREEN | BLUE | ALPHA) })] }), multiview: None }
2024-04-19 04:54:50.638  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created render pipeline Valid((4, 1, Vulkan)) with RenderPipelineDescriptor { label: Some("copy_deferred_lighting_id_pipeline"), layout: Some((3, 1, Vulkan)), vertex: VertexState { stage: ProgrammableStageDescriptor { module: (4, 1, Vulkan), entry_point: "fullscreen_vertex_shader" }, buffers: [] }, primitive: PrimitiveState { topology: TriangleList, strip_index_format: None, front_face: Ccw, cull_mode: None, unclipped_depth: false, polygon_mode: Fill, conservative: false }, depth_stencil: Some(DepthStencilState { format: Depth16Unorm, depth_write_enabled: true, depth_compare: Always, stencil: StencilState { front: StencilFaceState { compare: Always, fail_op: Keep, depth_fail_op: Keep, pass_op: Keep }, back: StencilFaceState { compare: Always, fail_op: Keep, depth_fail_op: Keep, pass_op: Keep }, read_mask: 0, write_mask: 0 }, bias: DepthBiasState { constant: 0, slope_scale: 0.0, clamp: 0.0 } }), multisample: MultisampleState { count: 1, mask: 18446744073709551615, alpha_to_coverage_enabled: false }, fragment: Some(FragmentState { stage: ProgrammableStageDescriptor { module: (5, 1, Vulkan), entry_point: "fragment" }, targets: [] }), multiview: None }
2024-04-19 04:54:50.640  4665-4665  bevy_in_app::ffi::and.. name.jinleili.bevy.debug             I  Bevy App created!
2024-04-19 04:54:50.641  4665-4665  System.out              name.jinleili.bevy.debug             I  bevy_app 133887917839280
2024-04-19 04:54:50.653  4665-4665  System.out              name.jinleili.bevy.debug             I  Surface Creation Successful
2024-04-19 04:54:50.692  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:54:50.695  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  configuring surface with SurfaceConfiguration { usage: TextureUsages(RENDER_ATTACHMENT), format: Rgba8UnormSrgb, width: 1079, height: 1729, present_mode: Fifo, alpha_mode: Auto, view_formats: [] }
2024-04-19 04:54:50.697  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Automatically choosing alpha mode by rule Auto. Chose Inherit
2024-04-19 04:54:50.724  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created texture Valid((13, 1, Vulkan)) with TextureDescriptor { label: Some("main_texture_a"), size: Extent3d { width: 1079, height: 1729, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: D2, format: Rgba8UnormSrgb, usage: TextureUsages(COPY_SRC | TEXTURE_BINDING | RENDER_ATTACHMENT), view_formats: [] }
2024-04-19 04:54:50.725  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created texture Valid((14, 1, Vulkan)) with TextureDescriptor { label: Some("main_texture_b"), size: Extent3d { width: 1079, height: 1729, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 1, dimension: D2, format: Rgba8UnormSrgb, usage: TextureUsages(COPY_SRC | TEXTURE_BINDING | RENDER_ATTACHMENT), view_formats: [] }
2024-04-19 04:54:50.780  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created texture Valid((15, 1, Vulkan)) with TextureDescriptor { label: Some("main_texture_sampled"), size: Extent3d { width: 1079, height: 1729, depth_or_array_layers: 1 }, mip_level_count: 1, sample_count: 4, dimension: D2, format: Rgba8UnormSrgb, usage: TextureUsages(RENDER_ATTACHMENT), view_formats: [] }
2024-04-19 04:54:50.790  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created render pipeline Valid((5, 1, Vulkan)) with RenderPipelineDescriptor { label: Some("blit pipeline"), layout: Some((4, 1, Vulkan)), vertex: VertexState { stage: ProgrammableStageDescriptor { module: (4, 1, Vulkan), entry_point: "fullscreen_vertex_shader" }, buffers: [] }, primitive: PrimitiveState { topology: TriangleList, strip_index_format: None, front_face: Ccw, cull_mode: None, unclipped_depth: false, polygon_mode: Fill, conservative: false }, depth_stencil: None, multisample: MultisampleState { count: 1, mask: 18446744073709551615, alpha_to_coverage_enabled: false }, fragment: Some(FragmentState { stage: ProgrammableStageDescriptor { module: (6, 1, Vulkan), entry_point: "fs_main" }, targets: [Some(ColorTargetState { format: Rgba8UnormSrgb, blend: None, write_mask: ColorWrites(RED | GREEN | BLUE | ALPHA) })] }), multiview: None }
2024-04-19 04:54:50.811  4665-4665  wgpu_core::device::gl.. name.jinleili.bevy.debug             I  Created render pipeline Valid((6, 1, Vulkan)) with RenderPipelineDescriptor { label: Some("tonemapping pipeline"), layout: Some((5, 1, Vulkan)), vertex: VertexState { stage: ProgrammableStageDescriptor { module: (4, 1, Vulkan), entry_point: "fullscreen_vertex_shader" }, buffers: [] }, primitive: PrimitiveState { topology: TriangleList, strip_index_format: None, front_face: Ccw, cull_mode: None, unclipped_depth: false, polygon_mode: Fill, conservative: false }, depth_stencil: None, multisample: MultisampleState { count: 1, mask: 18446744073709551615, alpha_to_coverage_enabled: false }, fragment: Some(FragmentState { stage: ProgrammableStageDescriptor { module: (7, 1, Vulkan), entry_point: "fragment" }, targets: [Some(ColorTargetState { format: Rgba16Float, blend: None, write_mask: ColorWrites(RED | GREEN | BLUE | ALPHA) })] }), multiview: None }
2024-04-19 04:54:50.816  4665-4665  goldfish_vulkan         name.jinleili.bevy.debug             D  ensureSyncDeviceFd: created sync device for current Vulkan process: 99
2024-04-19 04:54:50.819  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:54:51.676  4665-4717  SurfaceSyncGroup        name.jinleili.bevy.debug             E  Failed to receive transaction ready in 1000ms. Marking SurfaceSyncGroup(wmsSync-VRI[MainActivity]#1) as ready
2024-04-19 04:54:51.677  4665-4717  SurfaceSyncGroup        name.jinleili.bevy.debug             E  Failed to receive transaction ready in 1000ms. Marking SurfaceSyncGroup(VRI[MainActivity]#2) as ready
2024-04-19 04:54:52.213  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:54:53.145  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:54:55.691  4665-4681  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=7476ms; Flags=1, FrameTimelineVsyncId=11928, IntendedVsync=139764858735, Vsync=140298192047, InputEventId=0, HandleInputStart=140303633004, AnimationStart=140303644721, PerformTraversalsStart=140303961022, DrawStart=142273886671, FrameDeadline=139781525401, FrameInterval=140302155027, FrameStartTime=16666666, SyncQueued=145741657106, SyncStart=145742081624, IssueDrawCommandsStart=145743229229, SwapBuffers=146803573466, FrameCompleted=147242101490, DequeueBufferDuration=18427762, QueueBufferDuration=843565, GpuCompleted=147223555125, SwapBuffersCompleted=147242101490, DisplayPresentTime=0, CommandSubmissionCompleted=146803573466, 
2024-04-19 04:54:55.826  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 420 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:54:55.905  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:54:55.914  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:54:57.021  4665-4725  ProfileInstaller        name.jinleili.bevy.debug             D  Installing profile for name.jinleili.bevy.debug
2024-04-19 04:54:57.037  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 68 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:54:57.042  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:54:57.164  4665-4681  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=8280ms; Flags=0, FrameTimelineVsyncId=12079, IntendedVsync=140414858709, Vsync=147414858429, InputEventId=0, HandleInputStart=147425076324, AnimationStart=147425086504, PerformTraversalsStart=147492778899, DrawStart=147494076327, FrameDeadline=147248191769, FrameInterval=147422493876, FrameStartTime=16666666, SyncQueued=148507230394, SyncStart=148507288683, IssueDrawCommandsStart=148507384915, SwapBuffers=148508563633, FrameCompleted=148695096678, DequeueBufferDuration=4306490, QueueBufferDuration=302303, GpuCompleted=148695096678, SwapBuffersCompleted=148559441446, DisplayPresentTime=35192962104232, CommandSubmissionCompleted=148508563633, 
2024-04-19 04:54:57.872  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:54:58.636  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 45 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:54:58.640  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:54:58.650  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=1500.10ms min=1310.37ms max=1689.83ms count=2
2024-04-19 04:54:58.723  4665-4681  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=2788ms; Flags=0, FrameTimelineVsyncId=12683, IntendedVsync=147498191759, Vsync=148631525047, InputEventId=0, HandleInputStart=148634333192, AnimationStart=148634340934, PerformTraversalsStart=148634350552, DrawStart=148637211820, FrameDeadline=148714858377, FrameInterval=148633796213, FrameStartTime=16666666, SyncQueued=150223044218, SyncStart=150223104762, IssueDrawCommandsStart=150223151875, SwapBuffers=150228910050, FrameCompleted=150286541561, DequeueBufferDuration=9520, QueueBufferDuration=491173, GpuCompleted=150286541561, SwapBuffersCompleted=150258830583, DisplayPresentTime=35192962096925, CommandSubmissionCompleted=150228910050, 
2024-04-19 04:54:59.368  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:00.014  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 37 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:55:00.016  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:00.022  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=1371.49ms min=1371.49ms max=1371.49ms count=1
2024-04-19 04:55:00.629  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:00.658  4665-4681  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=2750ms; Flags=0, FrameTimelineVsyncId=12840, IntendedVsync=149481525013, Vsync=150231524983, InputEventId=0, HandleInputStart=150232834895, AnimationStart=150232841813, PerformTraversalsStart=150232847780, DrawStart=150236061297, FrameDeadline=150314858313, FrameInterval=150232434317, FrameStartTime=16666666, SyncQueued=151609435164, SyncStart=151609494163, IssueDrawCommandsStart=151609540153, SwapBuffers=151610235832, FrameCompleted=152231761798, DequeueBufferDuration=9172, QueueBufferDuration=237027, GpuCompleted=152231761798, SwapBuffersCompleted=151619631403, DisplayPresentTime=35192962104278, CommandSubmissionCompleted=151610235832, 
2024-04-19 04:55:01.252  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 37 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:55:01.256  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=1233.07ms min=1233.07ms max=1233.07ms count=1
2024-04-19 04:55:01.256  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:01.329  4665-4726  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=1933ms; Flags=0, FrameTimelineVsyncId=12949, IntendedVsync=150981524953, Vsync=151598191595, InputEventId=0, HandleInputStart=151611727803, AnimationStart=151611733254, PerformTraversalsStart=151611741074, DrawStart=151612182915, FrameDeadline=152264858235, FrameInterval=151610741350, FrameStartTime=16666666, SyncQueued=152846448418, SyncStart=152846551199, IssueDrawCommandsStart=152846618944, SwapBuffers=152847400472, FrameCompleted=152915055248, DequeueBufferDuration=9193, QueueBufferDuration=528535, GpuCompleted=152915055248, SwapBuffersCompleted=152852877162, DisplayPresentTime=35205847079489, CommandSubmissionCompleted=152847400472, 
2024-04-19 04:55:01.863  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:02.448  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=1192.13ms min=1192.13ms max=1192.13ms count=1
2024-04-19 04:55:02.449  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 34 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:55:02.451  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:03.048  4665-4726  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=1818ms; Flags=0, FrameTimelineVsyncId=13086, IntendedVsync=152231524903, Vsync=152848191545, InputEventId=0, HandleInputStart=152851314062, AnimationStart=152851321862, PerformTraversalsStart=152851326278, DrawStart=152851851919, FrameDeadline=152948191541, FrameInterval=152848725412, FrameStartTime=16666666, SyncQueued=154030936305, SyncStart=154030988983, IssueDrawCommandsStart=154031024511, SwapBuffers=154031597555, FrameCompleted=154050451184, DequeueBufferDuration=7467, QueueBufferDuration=237458, GpuCompleted=154050451184, SwapBuffersCompleted=154045208676, DisplayPresentTime=35188667122368, CommandSubmissionCompleted=154031597555, 
2024-04-19 04:55:03.056  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:03.670  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 36 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:55:03.673  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:03.733  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=1285.07ms min=1285.07ms max=1285.07ms count=1
2024-04-19 04:55:04.249  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:04.258  4665-4681  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=2377ms; Flags=0, FrameTimelineVsyncId=13174, IntendedVsync=153464858187, Vsync=154031524831, InputEventId=0, HandleInputStart=154046149773, AnimationStart=154046154642, PerformTraversalsStart=154046159725, DrawStart=154046561863, FrameDeadline=154081524829, FrameInterval=154045800858, FrameStartTime=16666666, SyncQueued=155264417511, SyncStart=155264523913, IssueDrawCommandsStart=155264560899, SwapBuffers=155265042422, FrameCompleted=155842610902, DequeueBufferDuration=7892, QueueBufferDuration=302208, GpuCompleted=155842610902, SwapBuffersCompleted=155330385658, DisplayPresentTime=0, CommandSubmissionCompleted=155265042422, 
2024-04-19 04:55:04.818  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 33 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:55:04.821  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=1087.90ms min=1087.90ms max=1087.90ms count=1
2024-04-19 04:55:04.824  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:05.461  4665-4681  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=1769ms; Flags=0, FrameTimelineVsyncId=13225, IntendedVsync=154664858139, Vsync=155264858115, InputEventId=0, HandleInputStart=155266813354, AnimationStart=155266821502, PerformTraversalsStart=155266826159, DrawStart=155267607601, FrameDeadline=155864858091, FrameInterval=155266342991, FrameStartTime=16666666, SyncQueued=156412998527, SyncStart=156413087186, IssueDrawCommandsStart=156413122206, SwapBuffers=156413591706, FrameCompleted=156434502504, DequeueBufferDuration=6452, QueueBufferDuration=354233, GpuCompleted=156434502504, SwapBuffersCompleted=156418353223, DisplayPresentTime=35184372228415, CommandSubmissionCompleted=156413591706, 
2024-04-19 04:55:05.490  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:06.521  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 61 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:55:06.555  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:06.604  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=1781.51ms min=1781.51ms max=1781.51ms count=1
2024-04-19 04:55:07.322  4665-4726  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=2357ms; Flags=0, FrameTimelineVsyncId=13310, IntendedVsync=155848191425, Vsync=156398191403, InputEventId=0, HandleInputStart=156419452102, AnimationStart=156419457748, PerformTraversalsStart=156419461717, DrawStart=156419825215, FrameDeadline=156464858067, FrameInterval=156414737168, FrameStartTime=16666666, SyncQueued=158095892797, SyncStart=158105738430, IssueDrawCommandsStart=158106297125, SwapBuffers=158146673137, FrameCompleted=158215370062, DequeueBufferDuration=22063, QueueBufferDuration=1404973, GpuCompleted=158215370062, SwapBuffersCompleted=158201483621, DisplayPresentTime=35192962104393, CommandSubmissionCompleted=158146673137, 
2024-04-19 04:55:07.354  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:08.018  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=1413.37ms min=1413.37ms max=1413.37ms count=1
2024-04-19 04:55:08.040  4665-4665  System.out              name.jinleili.bevy.debug             I  Going to next game
2024-04-19 04:55:08.046  4665-4681  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=2516ms; Flags=0, FrameTimelineVsyncId=13361, IntendedVsync=157098191375, Vsync=158114858001, InputEventId=0, HandleInputStart=158119064070, AnimationStart=158119070990, PerformTraversalsStart=158119081943, DrawStart=158133951852, FrameDeadline=158248191329, FrameInterval=158116937520, FrameStartTime=16666666, SyncQueued=159606586092, SyncStart=159606723269, IssueDrawCommandsStart=159607049486, SwapBuffers=159609318469, FrameCompleted=159614952141, DequeueBufferDuration=7599, QueueBufferDuration=688897, GpuCompleted=159614716651, SwapBuffersCompleted=159614952141, DisplayPresentTime=35192962148394, CommandSubmissionCompleted=159609318469, 
2024-04-19 04:55:08.097  4665-4665  System.out              name.jinleili.bevy.debug             I  Successful
2024-04-19 04:55:08.099  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 44 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:55:08.141  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:08.714  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:09.399  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 74 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:55:09.402  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:09.663  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=1644.73ms min=1644.73ms max=1644.73ms count=1
2024-04-19 04:55:10.058  4665-4726  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=2316ms; Flags=0, FrameTimelineVsyncId=13442, IntendedVsync=158948191301, Vsync=159681524605, InputEventId=833571822, HandleInputStart=159696057179, AnimationStart=159696061954, PerformTraversalsStart=159734623817, DrawStart=159736190941, FrameDeadline=159631524607, FrameInterval=159695634269, FrameStartTime=16666666, SyncQueued=160985922111, SyncStart=160986126344, IssueDrawCommandsStart=160986201287, SwapBuffers=161032012531, FrameCompleted=161265020811, DequeueBufferDuration=8266, QueueBufferDuration=303904, GpuCompleted=161265020811, SwapBuffersCompleted=161259959336, DisplayPresentTime=35192962100774, CommandSubmissionCompleted=161032012531, 
2024-04-19 04:55:10.087  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:10.789  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=30.52ms min=7.36ms max=75.81ms count=5
2024-04-19 04:55:10.887  4665-4665  System.out              name.jinleili.bevy.debug             I  Creating BevyActivity
2024-04-19 04:55:10.943  4665-4665  System.out              name.jinleili.bevy.debug             I  BevyActivity Content Set
2024-04-19 04:55:11.465  4665-4726  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=3238ms; Flags=0, FrameTimelineVsyncId=13515, IntendedVsync=159748191269, Vsync=160981524553, InputEventId=0, HandleInputStart=160995767197, AnimationStart=160995772803, PerformTraversalsStart=160996417730, DrawStart=160997042103, FrameDeadline=162498191159, FrameInterval=160995233518, FrameStartTime=16666666, SyncQueued=162391944479, SyncStart=162454782984, IssueDrawCommandsStart=162454847723, SwapBuffers=162489336150, FrameCompleted=163049456416, DequeueBufferDuration=535207977, QueueBufferDuration=244582, GpuCompleted=163049234978, SwapBuffersCompleted=163049456416, DisplayPresentTime=35184372228642, CommandSubmissionCompleted=162489336150, 
2024-04-19 04:55:11.493  4665-4665  Choreographer           name.jinleili.bevy.debug             I  Skipped 124 frames!  The application may be doing too much work on its main thread.
2024-04-19 04:55:11.496  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:11.519  4665-4665  System.out              name.jinleili.bevy.debug             I  Draw Started
2024-04-19 04:55:12.275  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=47.97ms min=21.55ms max=66.42ms count=7
2024-04-19 04:55:12.288  4665-4665  AutofillManager         name.jinleili.bevy.debug             D  Fill dialog is enabled:false, hints=[password, passwordAuto, creditCardNumber, creditCardSecurityCode, creditCardExpirationDate]
2024-04-19 04:55:12.342  4665-4665  System.out              name.jinleili.bevy.debug             I  Surface Card of Bevy Activity
2024-04-19 04:55:12.342  4665-4665  System.out              name.jinleili.bevy.debug             I  Let's create column
2024-04-19 04:55:12.343  4665-4665  System.out              name.jinleili.bevy.debug             I  Creating column
2024-04-19 04:55:12.344  4665-4665  System.out              name.jinleili.bevy.debug             I  Creating Row
2024-04-19 04:55:12.351  4665-4665  System.out              name.jinleili.bevy.debug             I  Finished Bevy Activity Surface Card
2024-04-19 04:55:12.355  4665-4665  System.out              name.jinleili.bevy.debug             I  Creating Android View
2024-04-19 04:55:12.356  4665-4665  System.out              name.jinleili.bevy.debug             I  Holder callback
2024-04-19 04:55:12.359  4665-4665  System.out              name.jinleili.bevy.debug             I  Lib name: bevy_in_ass
2024-04-19 04:55:12.864  4665-4681  OpenGLRenderer          name.jinleili.bevy.debug             I  Davey! duration=3388ms; Flags=0, FrameTimelineVsyncId=13550, IntendedVsync=161014857885, Vsync=163081524469, InputEventId=0, HandleInputStart=163090895333, AnimationStart=163090903611, PerformTraversalsStart=163091035436, DrawStart=163091553531, FrameDeadline=163898191103, FrameInterval=163089632659, FrameStartTime=16666666, SyncQueued=163840910399, SyncStart=163872363195, IssueDrawCommandsStart=163872440043, SwapBuffers=163873156701, FrameCompleted=164435083399, DequeueBufferDuration=542030474, QueueBufferDuration=223334, GpuCompleted=164434875350, SwapBuffersCompleted=164435083399, DisplayPresentTime=35188667115452, CommandSubmissionCompleted=163873156701, 
2024-04-19 04:55:13.070  4665-4665  System.out              name.jinleili.bevy.debug             I  Surface Creating
2024-04-19 04:55:13.074  4665-4665  System.out              name.jinleili.bevy.debug             I  ndk inited
2024-04-19 04:55:13.074  4665-4665  System.out              name.jinleili.bevy.debug             I  name.jinleili.bevy.BevyActivity@17a5f24
2024-04-19 04:55:13.075  4665-4665  System.out              name.jinleili.bevy.debug             I  name.jinleili.bevy.RustBridge@3efaa8d
2024-04-19 04:55:13.075  4665-4665  log_panics              name.jinleili.bevy.debug             E  thread '<unnamed>' panicked at 'assertion failed: previous.is_none()': /home/souvikinator/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ndk-context-0.1.1/src/lib.rs:87
2024-04-19 04:55:13.169  4665-4665  libc                    name.jinleili.bevy.debug             A  Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 4665 (eili.bevy.debug), pid 4665 (eili.bevy.debug)
2024-04-19 04:55:13.278  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=34.61ms min=7.75ms max=69.29ms count=10
2024-04-19 04:55:14.352  4665-4692  EGL_emulation           name.jinleili.bevy.debug             D  app_time_stats: avg=54.15ms min=25.72ms max=129.63ms count=16
2024-04-19 04:55:15.700  4741-4741  DEBUG                   crash_dump64                         A  Cmdline: name.jinleili.bevy.debug
2024-04-19 04:55:15.700  4741-4741  DEBUG                   crash_dump64                         A  pid: 4665, tid: 4665, name: eili.bevy.debug  >>> name.jinleili.bevy.debug <<<
2024-04-19 04:55:15.700  4741-4741  DEBUG                   crash_dump64                         A        #01 pc 0000000001b24ae6  /data/app/~~CGPsrT9rVbwFFxv5X_aU9w==/name.jinleili.bevy.debug-ye2Stlfir8lwrK7i_SJfLg==/base.apk (offset 0x316b000)
2024-04-19 04:55:15.701  4741-4741  DEBUG                   crash_dump64                         A        #02 pc 0000000001b215f8  /data/app/~~CGPsrT9rVbwFFxv5X_aU9w==/name.jinleili.bevy.debug-ye2Stlfir8lwrK7i_SJfLg==/base.apk (offset 0x316b000)
2024-04-19 04:55:15.701  4741-4741  DEBUG                   crash_dump64                         A        #03 pc 0000000001b213a8  /data/app/~~CGPsrT9rVbwFFxv5X_aU9w==/name.jinleili.bevy.debug-ye2Stlfir8lwrK7i_SJfLg==/base.apk (offset 0x316b000)
2024-04-19 04:55:15.701  4741-4741  DEBUG                   crash_dump64                         A        #04 pc 0000000001b21068  /data/app/~~CGPsrT9rVbwFFxv5X_aU9w==/name.jinleili.bevy.debug-ye2Stlfir8lwrK7i_SJfLg==/base.apk (offset 0x316b000)
2024-04-19 04:55:15.701  4741-4741  DEBUG                   crash_dump64                         A        #05 pc 0000000001b1fb05  /data/app/~~CGPsrT9rVbwFFxv5X_aU9w==/name.jinleili.bevy.debug-ye2Stlfir8lwrK7i_SJfLg==/base.apk (offset 0x316b000)
2024-04-19 04:55:15.701  4741-4741  DEBUG                   crash_dump64                         A        #06 pc 0000000001b20df3  /data/app/~~CGPsrT9rVbwFFxv5X_aU9w==/name.jinleili.bevy.debug-ye2Stlfir8lwrK7i_SJfLg==/base.apk (offset 0x316b000)
2024-04-19 04:55:15.701  4741-4741  DEBUG                   crash_dump64                         A        #07 pc 0000000001b44cd4  /data/app/~~CGPsrT9rVbwFFxv5X_aU9w==/name.jinleili.bevy.debug-ye2Stlfir8lwrK7i_SJfLg==/base.apk (offset 0x316b000)
2024-04-19 04:55:15.701  4741-4741  DEBUG                   crash_dump64                         A        #08 pc 0000000001b44d92  /data/app/~~CGPsrT9rVbwFFxv5X_aU9w==/name.jinleili.bevy.debug-ye2Stlfir8lwrK7i_SJfLg==/base.apk (offset 0x316b000)
2024-04-19 04:55:15.701  4741-4741  DEBUG                   crash_dump64                         A        #09 pc 00000000018bc04a  /data/app/~~CGPsrT9rVbwFFxv5X_aU9w==/name.jinleili.bevy.debug-ye2Stlfir8lwrK7i_SJfLg==/base.apk (offset 0x316b000)
2024-04-19 04:55:15.701  4741-4741  DEBUG                   crash_dump64                         A        #10 pc 0000000000953eca  /data/app/~~CGPsrT9rVbwFFxv5X_aU9w==/name.jinleili.bevy.debug-ye2Stlfir8lwrK7i_SJfLg==/base.apk (offset 0x316b000) (Java_name_jinleili_bevy_RustBridge_init_1ndk_1context+122)
2024-04-19 04:55:15.702  4741-4741  DEBUG                   crash_dump64                         A        #17 pc 00000000000037bc  /data/data/name.jinleili.bevy.debug/code_cache/.overlay/base.apk/classes4.dex (name.jinleili.bevy.BevySurfaceView.surfaceCreated+0)

Any idea why it is happening?

安卓后台之后会导致panic

老师你好
我在运行项目时发现这样的问题
在将app切至后台之后再切出来会崩,问题在于多次初始化context,在将初始化移至init块之后避免了这个问题,但是仍然会多次实例化bevy
ps. 我并不懂安卓,因为想把bevy塞进app才开始研究

根据描述,本案例是作为开屏小游戏
我这边是想把bevy作为主要内容,所以出现了此问题
请老师指点

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.